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

Allow RW auth to use capitalised authorization header #3829

Merged

Conversation

Irev-Dev
Copy link
Contributor

@Irev-Dev Irev-Dev commented Dec 3, 2021

Deploying to AWS (with serverless) seems to transform the authorization header to be
captialised "Authorization".

This causes the auth to fail.

I found this from my own experience deploying this test project:
https://github.com/Irev-Dev/redwood-serverless-cors-demo
Which I was able to resolve with this change.

Besides my own experience I tried to find docs confirming this, I found
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html
Which says:
"Header names and query parameters are processed in a case-sensitive way."

and lists authorization with a capital "A", it doesn't explicitly say
the header is transformed to uppercase, but I think it's implied.

Besides AWS, it's plausible that future deploy targets will have the same quirk, this change only makes the auth more robust.

Here's a screen shot from my Cloudwatch logs that show shows the "The Authorization header is not valid." error I was getting before the fix as well as the headers logged out showing the case of the authorization header.
image

Deploying to AWS (with serverless) seems to transform the authorization header to be
captialised "Authorization".

This causes the auth to fail.

I found this from my own experience deploying this test project
https://github.com/Irev-Dev/redwood-serverless-cors-demo

Besides my own experience I tried to find docs confirming this, I found
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html
Which says:
"Header names and query parameters are processed in a case-sensitive way."

and lists authorization with a capital "A", it doesn't explicitly say
the header is transformed to uppercase, but I think it's implied.

Besides AWS I think it somewhat likely that other deploy targets in the
future might have the same quirk so this only seems to make the auth
provider more robust.
@Irev-Dev
Copy link
Contributor Author

Irev-Dev commented Dec 3, 2021

For context I found this when looking into #3812.

@Irev-Dev
Copy link
Contributor Author

Irev-Dev commented Dec 3, 2021

|'ve learned a little more since, This issue of the capitalised "Authorization" header only effects AWS's REST api, as opposed to the http api which doesn't have the same problem.

The current serverless setup command uses the http-api, and that's recommended (it's newer and faster) so maybe this PR isn't needed, but it's possible a RW user would switch to the old api.

@thedavidprice
Copy link
Contributor

@Irev-Dev it's a simple change that seem reasonable to me either way. Looping in @dthyresson for the offical go/no-go review.

@thedavidprice thedavidprice merged commit 30e5db2 into redwoodjs:main Dec 17, 2021
@Irev-Dev Irev-Dev deleted the kurt/get-case-insensitive-auth-header branch December 17, 2021 20:05
@thedavidprice thedavidprice modified the milestones: next-release, v0.41.0 Dec 21, 2021
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.

5 participants