`Authorization` header without scheme
See original GitHub issueThis package encourages use of Authorization
header values without a scheme token. Are you sure that’s valid HTTP? I’ve looked through RFC 2617 and RFC 7235 and it seems invalid to me. For example, here is the grammar showing scheme (auth-scheme
) as a required part of the Authorization
value. The prose and grammar elsewhere in the spec and in RFC 2617 lead me to the same conclusion.
https://github.com/dwyl/hapi-auth-jwt2/pull/105#issuecomment-140690731 included the following content (formatted as a quote):
The wording in RFC 2617 is “Should” not “Must” which means its a suggestion not a requirement.
Was that a quote or the author’s own words? In any case, can you please provide a specific reference to the section and content it’s based on?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Using HttpClient, send an Authorization token with no schema
Note the absence of any authentication scheme. I have tried doing: myHttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.
Read more >Authorization - HTTP - MDN Web Docs - Mozilla
This header indicates what authentication schemes can be used to access the resource (and any additional information needed by the client to use ......
Read more >AuthenticationHeaderValue without "Scheme" - MSDN
Hello. I need to set the "AuthenticationHeaderValue" of a "HttpClient" request. The problem is that usign the code: request.
Read more >Basic access authentication - Wikipedia
The Authorization header field is constructed as follows: The username and password are combined with a single colon (:). This means that the...
Read more >Bearer Authentication - Swagger
The client must send this token in the Authorization header when making ... The Bearer authentication scheme was originally created as part of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nelsonic Sounds good. I forgot to mention an important wrinkle: the header name is configurable. So I think that makes sense when the header is
Authorization
, but when using a custom header I guess anything goes and it’s fair game to set the value to just the bearer token.It’d probably be a good idea to link from the
headerKey
option docs to the RFC 7235 comments on caching (unfortunately they didn’t number the items in that section; it’s the last list item):@nelsonic Thanks for the reply. I actually misstated the problem a little bit (but the upshot here is the same). I said:
It appears to me that the HTTP grammar for
Authorization
permits a value (credentials
) that consists only of a scheme (auth-scheme
). (I don’t actually understand why that is.) So when this plugin accepts a header like……it seems to me that it’s using the scheme component as the token value. To illustrate, imagine that instead of the raw header value you had an API for retrieving the parsed components of HTTP header values, with an
authorization
interface withauthScheme
andtoken
accessors. It seems to me that what this plugin is doing is equivalent to:It looks like the
Bearer
scheme is proposed in RFC 6750. And I guess IANA runs a registry for HTTP auth schemes that includes it. From my reading of RFC 6750 (2.1) theBearer
scheme is required:And from my reading of RFC 7235 (or 2617) it doesn’t seem valid to “omit” the scheme by interpreting the first token (component) of the header value as the bearer token instead of as the scheme.
Does it work anyway, yes (at least in this context), but it doesn’t seem like a great idea to me to intentionally violate the protocol.
I don’t think that’d be the section in any case because Section 3.2.2 of RFC 2617 relates to the
Digest
auth scheme whereas RFC 6750 (Bearer
scheme) says:Well, I think either of those is entirely possible 😃 It could be you saw that in some earlier version of one of these RFCs or another document. (I was just looking at a situation where something about clients sending the
Origin
header changed from MUST to SHOULD [or vice versa] in a later version of the spec due to web compat considerations that came to light.) I also think it’s not too hard to get turned around while going through these specs (individually and even more so when going through several). I don’t rule out that it’s happening to me right now 😃