Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Purpuse of lower casing header option #52

Closed
jumika opened this issue Jan 16, 2018 · 3 comments
Closed

Purpuse of lower casing header option #52

jumika opened this issue Jan 16, 2018 · 3 comments

Comments

@jumika
Copy link

jumika commented Jan 16, 2018

I'm wondering what is the purpuse of toLowerCase in the code below:

let strategyOptions = merge({
      secretOrKey: jwtSettings.secret,
      jwtFromRequest: ExtractJwt.fromExtractors([
        ExtractJwt.fromAuthHeaderWithScheme('jwt'),
        ExtractJwt.fromAuthHeaderAsBearerToken(),
        ExtractJwt.fromHeader(jwtSettings.header.toLowerCase()),
        ExtractJwt.fromBodyField(jwtSettings.bodyKey)
      ])
    }, jwtSettings.jwt, omit(jwtSettings, ['jwt', 'header', 'secret']));
@daffl
Copy link
Member

daffl commented Jan 16, 2018

Casing generally shouldn't matter for HTTP headers but you still need a format to check against, the preferred one usually being all lowercase since it's easy to convert. Not sure if ExtractJwt.fromHeader already takes care of it but we figured it doesn't really hurt to do it anyway.

@jumika
Copy link
Author

jumika commented Jan 16, 2018

Thanks for the answer.
I'm trying to simulate a client request on the server api for server side rendering. What i'm doing is reading the jwt from a cookie, then setting it as param.headers.Authorization for every service call. That's how i got fooled by the lower casing.
I don't get how this header get lower cased when using the rest api for example, as the default setting for the jwt header is "Authorization".
I'm trying to understand why the default value has upper case initial if the hook checks for a lower case variation.

@daffl
Copy link
Member

daffl commented Jan 16, 2018

Are you running into issues? I don't think this should affect anything in how it is used.

@daffl daffl closed this as completed Jan 19, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants