Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding SERVICE_TOKEN_SECRET to Rust SDK Serve command #27

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

sordina
Copy link
Contributor

@sordina sordina commented Sep 13, 2023

This is to be used in conjunction with the changes made to V3 engine that can send a pre-shared secret token via Authorization: Bearer TOKEN header.

If the SERVICE_TOKEN_SECRET env variable is set or the engine sends the Authorization: Bearer SERVICE_TOKEN_SECRET header, then the values must match.

If they do not match then the response will be StatusCode::UNAUTHORIZED.

If neither are set then the request proceeds as before.

@sordina sordina requested a review from paf31 September 13, 2023 01:49
@sordina sordina self-assigned this Sep 13, 2023
TraceLayer::new_for_http().make_span_with(DefaultMakeSpan::default().level(Level::INFO)),
);
let expected_auth_header: Option<HeaderValue> = serve_command.service_token_secret.and_then(|service_token_secret| {
let expected_bearer = format!("Bearer {}", service_token_secret); // TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the "TODO" comment there any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmoverton done

Copy link
Contributor

@dmoverton dmoverton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@sordina sordina merged commit d67520a into main Sep 14, 2023
2 checks passed

// NOTE: The comparison should probably be more permissive to allow for whitespace, etc.
if auth_header == expected_auth_header { return Ok(()); }
Err((StatusCode::UNAUTHORIZED, "").into_response())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice this before but this should return an ErrorResponse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an example of how to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#35

@SamirTalwar SamirTalwar deleted the lyndon/shared-secret-connector-service-auth branch October 24, 2023 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants