Skip to content

Commit

Permalink
Trace first, then auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirTalwar committed May 13, 2024
1 parent a273a01 commit 64511f2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/sdk/src/default_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ where
.route("/query/explain", post(post_query_explain::<C>))
.route("/mutation", post(post_mutation::<C>))
.route("/mutation/explain", post(post_mutation_explain::<C>))
.with_state(state)
.layer(ValidateRequestHeaderLayer::custom(auth_handler(
service_token_secret,
)))
.layer(
TraceLayer::new_for_http()
.make_span_with(make_span)
Expand All @@ -319,10 +323,6 @@ where
);
}),
)
.with_state(state)
.layer(ValidateRequestHeaderLayer::custom(auth_handler(
service_token_secret,
)))
}

fn auth_handler(
Expand All @@ -336,10 +336,10 @@ fn auth_handler(

move |request| {
// Validate the request
let auth_header = request.headers().get("Authorization").cloned();
let auth_header = request.headers().get("Authorization");

// NOTE: The comparison should probably be more permissive to allow for whitespace, etc.
if auth_header == expected_auth_header {
if auth_header == expected_auth_header.as_ref() {
return Ok(());
}

Expand Down

0 comments on commit 64511f2

Please sign in to comment.