-
Notifications
You must be signed in to change notification settings - Fork 49
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
Scheme(s) should not be discared when alternate header is used #286
Comments
@abutic Hi Now if we have
then indeed That said, another alternative is to deal with the forwarded header in the filter dealing with the |
@sberyozkin Hi, thanks for the quick reply! Yes, my guess was that you're making an assumption that alternate header contains the value directly, that's why I didn't categorically say it was a bug. :-) I guess there's no standard dealing with it, so it can go either way. I can speak for myself: my expectaion was, after reading the docs, that header value would be treated the same way, no matter which header contained it, Their is no mention of
That sound good! It's an elegant way of dealing with this kind of situation, instead of introducing yet another config param, something like Yes, we're using Quarkus. You're suggesting using a request filter to modify the header? |
I'm not 100% sure, but it feels that in this specific case, |
@sberyozkin Are you the man in charge of that? I mean, is it your decision whether it will be supported in smallrye-jwt or not? It seems to me that the possibility of using Quarkus+SmallRye-JWT behind Google Endpoints v2 out-of-the-box, without header modifications made by filters, makes a pretty strong case. The case is even stronger if we take into account that changes needed for all this are fairly easy to implement. |
Is it intentional not to check for scheme(s) when alternate header is used or is it a bug?
When default
Authorization
header is used,smallrye.jwt.token.schemes
property is properly taken into account, but when alternate header name is used, for instance like this:smallrye.jwt.token.header=x-forwarded-authorization
you're then completely discarding
smallrye.jwt.token.schemes
property.Furthermore, you don't even allow a header value to contain any scheme.
For instance, if configured to use the default
Authorization
header, this header value is valid:Bearer <JWT token>
But if
smallrye.jwt.token.header
property is set, thenBearer <JWT token>
is not a valid header value.
Furthermore, any scheme name in front of a JWT itself is illegal, no matter if
smallrye.jwt.token.schemes
property is being used at all and no matter its value. Only this is valid header value ifsmallrye.jwt.token.header
property is set:<JWT token>
If this is a bug, it can be easily fixed by changing the
io.smallrye.jwt.auth.AbstractBearerTokenExtractor#getBearerToken
method here:smallrye-jwt/implementation/src/main/java/io/smallrye/jwt/auth/AbstractBearerTokenExtractor.java
Line 51 in 4bdcdf7
As you may guess, this is not an academic discussion: when Google Cloud Endpoints v2 is configured to use Firebase Auth, it forwards original
Authorization
header value asx-forwarded-authorization
header value. So, as the original header value is forwared "as is", it contains the "Bearer " prefix. Hence the trouble...The text was updated successfully, but these errors were encountered: