MCPcopy Create free account
hub / github.com/emwalker/digraph / viewer_from_header

Function viewer_from_header

backend/src/bin/api.rs:35–48  ·  view source on GitHub ↗
(
    auth: Option<TypedHeader<Authorization<Basic>>>,
    state: &digraph::graphql::State,
)

Source from the content-addressed store, hash-verified

33pub(crate) type ServiceSchema = Schema<QueryRoot, MutationRoot, EmptySubscription>;
34
35async 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)]
51struct Health {

Callers 1

graphql_handlerFunction · 0.85

Calls 1

authenticateMethod · 0.80

Tested by

no test coverage detected