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

add authorization_source feature #478

Merged
merged 2 commits into from
Jul 15, 2024
Merged

Conversation

tmokmss
Copy link
Contributor

@tmokmss tmokmss commented Jul 15, 2024

Issue #, if available:

#477

Description of changes:

Added AWS_LWA_AUTHORIZATION_SOURCE option to rename a specifed header name to Authorization. Details are in the linked issue.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

src/lib.rs Outdated

if !self.authorization_source.is_empty() && req_headers.contains_key(&self.authorization_source) {
let original = req_headers.remove(&self.authorization_source).unwrap();
req_headers.insert("authorization", original);
Copy link
Contributor Author

@tmokmss tmokmss Jul 15, 2024

Choose a reason for hiding this comment

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

HeaderMap is case-insensitive: https://docs.rs/http/latest/http/header/index.html

Header names are normalized to lower case.

so we just use authorization here.

// Start app server
let app_server = MockServer::start();
let hello = app_server.mock(|when, then| {
when.method(GET).path("/hello").header_exists("Authorization");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

header_exists makes requests fail if it does not contain Authorization header. https://docs.rs/httpmock/latest/httpmock/struct.When.html#method.header_exists

This effectively validates the authorization_source behavior.

src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@bnusunny bnusunny left a comment

Choose a reason for hiding this comment

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

LGTM

@bnusunny bnusunny merged commit c259bd8 into awslabs:main Jul 15, 2024
23 checks passed
@tmokmss tmokmss deleted the authorization-source branch July 15, 2024 08:39
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.

2 participants