Skip to content

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.

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
@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