fastify / fastify-jwt

JWT utils for Fastify
MIT License
514 stars 99 forks source link

If `authorization` is not of type Bearer to ignore it and check the cookie #318

Closed cberescu closed 10 months ago

cberescu commented 11 months ago

Prerequisites

🚀 Feature Proposal

I think it would help for the authorization header to be skipped if it is not Bearer type. No reason to throw an error if it is not the expected format.
Easies way to do it is to change this line if ((request.headers && request.headers.authorization) && (!onlyCookie)) into if ((request.headers && request.headers.authorization) && (!onlyCookie) && (/^Bearer/i.test(request.headers.authorization)))

Motivation

A good example is if you are using also the Basic auth on the same domain.

Example

No response

mcollina commented 10 months ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.