Bearer tokens should not be decoded
Currently bearer tokens are treated as base64 encoded strings. According to HTTP 1.1 and OAuth 2 they are not base64 but instead plain text with only base64 characters allowed.
Since access tokens already meet this requirement, the base64 encoding / decoding really has no real purpose AFAICT.
@rmg do you have any thoughts here?
The code you linked to is for Basic auth only, the handler for Bearer is a few lines above.
This is done because Basic auth specifies base64, and if you give a token as your user/pass and let the browser/curl/library pass it as basic auth, it will base64 what you give it.
@rmg I was looking at the wrong line... fixed the link.
Ah, I see now. I don't recall modifying that line. Might have just been a whitespace change. I tried not to modify any behavior other than the Basic auth case.
It's required by oAuth 2.0 Bearer token spec to be b64: https://tools.ietf.org/html/rfc6750#section-2.1
By checking https://github.com/jaredhanson/passport-http-bearer/blob/master/lib/strategy.js#L89-L101, it seems that the token value is not b64 decoded. Maybe b64 is just a recommended format for bearer tokens.
Maybe b64 is just a recommended format for bearer tokens.
Exactly. Should we remove the decoding then?
+1 Having this same issue. Bearer Tokens are not supposed to be encoded/decoded.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.