(
auth: Option<TypedHeader<Authorization<Basic>>>,
state: &digraph::graphql::State,
)
| 33 | pub(crate) type ServiceSchema = Schema<QueryRoot, MutationRoot, EmptySubscription>; |
| 34 | |
| 35 | async fn viewer_from_header( |
| 36 | auth: Option<TypedHeader<Authorization<Basic>>>, |
| 37 | state: &digraph::graphql::State, |
| 38 | ) -> Viewer { |
| 39 | if let Some(TypedHeader(auth)) = auth { |
| 40 | // https://docs.rs/axum-extra/latest/axum_extra/extract/cookie/struct.CookieJar.html |
| 41 | let user_id = auth.username().to_owned(); |
| 42 | let session_id = auth.password().to_owned(); |
| 43 | state.authenticate((user_id, session_id)).await |
| 44 | } else { |
| 45 | log::info!("no auth header found, proceeding as guest"); |
| 46 | Viewer::guest() |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | #[derive(Serialize)] |
| 51 | struct Health { |
no test coverage detected