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

Extractors.FromHeader should be case insensitive #179

Open
remie opened this issue May 27, 2019 · 2 comments
Open

Extractors.FromHeader should be case insensitive #179

remie opened this issue May 27, 2019 · 2 comments

Comments

@remie
Copy link

remie commented May 27, 2019

HTTP headers are case insensitive (see https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2).

This was fixed for fromAuthHeaderWithScheme in #118 but is still an issue in fromHeader.
EDIT: on closer inspection, the fix of #118 only makes the scheme case-insensitive. This issue still applies to fromAuthHeaderWithScheme as it assumes the authorization header to be lower case.

@mikenicholson
Copy link
Owner

As far as I understand it, node's HTTP modules takes care of lowercasing the headers on the incoming request object. See https://nodejs.org/api/http.html#http_message_headers.

Can you provide a code example that illustrates different behavior?

@SchroederSteffen
Copy link

ExtractJwt.fromHeader() isn't case-insensitive, because it tries to read the header with the given name without lowercasing it beforehand.
In the headers map, the names are in lowercase and the parameter value header_name therefore also needs to be in lowercase.

A solution would be to call header_name.toLowerCase().

if (request.headers[header_name]) {

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

No branches or pull requests

3 participants