-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Resolve HttpCredentialTransport dynamically #22483
Resolve HttpCredentialTransport dynamically #22483
Conversation
@FroMage I can also suggest a workaround, register a In |
I'll have to try this out in my app as soon as I get it to compile again. It's not clear to me if your PR should be enough or if I need your workaround too. |
Hi @FroMage, please try it, I'm quite sure the PR will address the problem you are seeing in a generic way; but the woraround should be also viable, we've had a few cases where the default authentication flow in the Quarkus Security does not work for some applications so in those cases registering a custom mechanism, possibly combing some of those provided by Quarkus works. PR should address it though but it will require Stuart's approval |
This now needs a rebase |
I can't say I know much about Quarkus OIDC, but this looks reasonable to me |
@geoand Thanks, I'll try to handle it before CR1 |
Thanks! Let me know if I can help somehow |
a24fc11
to
e827f7c
Compare
Nope, this doesn't work, and I get:
|
e827f7c
to
c977618
Compare
@geoand thanks, sorry I missed your comment :-) |
@FroMage It is still a draft, I did some good progress last Friday, see the added |
NP! |
1d933d6
to
7596a4d
Compare
178e10a
to
6a13cb1
Compare
6a13cb1
to
4545241
Compare
@stuartwdouglas, @FroMage This PR is now ready for review, I guess it is too late for 2.7.0.CR1 as it can be considered a bit sensitive. Please see the issue description for the justification for this PR. Summary:
@FroMage Can you test this PR please to confirm you can now combine JWT and OIDC web-app, and that #22404 can be resolved as well ? Tests confirm that yes but an extra test would help |
Ouch, still a random failure persists in Native, cancelled the build |
Lemme try it |
Yes, this works. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only reviewing as a tester, this works for me.
@FroMage Thanks, I've just fixed the native test failure, about to force push |
4545241
to
48b7229
Compare
Stuart, @stuartwdouglas, please review when you get a chance |
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building 48b7229
Full information is available in the Build summary check run. Failures⚙️ Gradle Tests - JDK 11 Windows #- Failing: integration-tests/gradle
📦 integration-tests/gradle✖
|
This test failure is not related |
48b7229
to
cfc6d8b
Compare
@stuartwdouglas I think we can give this PR a try and merge it and see if it can settle on main ? Please comment when you get a chance |
@sberyozkin @FroMage I'm facing the issue when using quarkus-smallrye-jwt(local JWT) and quarkus-oidc(JWT Keycloak) |
This PR replaces #22437, Fixes #22404 (which itself is a consequence of #22437 for @FroMage) and Fixes #22206.
The main problem right now is that
quarkus-oidc
always returnsbearer
as its transport which immediately conflicts withsmallrye-jwt
even whenquarkus-oidc
usesweb-app
/authorization code
only and @FroMage is not the first one who has seen this problem as a few users have tried to usesmallrye-jwt
alongsidequarkus-oidc/web-app
sincesmallrye-jwt
covers a few non-OIDC cases.Splitting
quarkus-oidc
intoquarkus-oidc-service
,quarkus-oidc-web-app
will solve this particular issue but I'm not sure it is worth it and will likely have side-effects (ex, service and web-app tenants will not be kept in the same map, not clear how to support thehybrid
flow, I think it makes sense to keep it all in one extension).So this PR proposes to resolve
HttpCredentialTransport
dynamically - it is the only way forquarkus-oidc
to correctly represent the current tenant's cred transport as bothservice
andweb-app
tenants can be combined.Originally
HttpAuthenticationMechanism.getCredentialTransport
was only used to fail when more than one auth mechanism with the same cred transport is used. Now it is also used to find the best candidate for a challenge (for ex, ifbasic
andoidc/web-app
are used and basic fails then it is guaranteedbasic
will return the challenge, even without the priority based sorting). It is also now used for a path-specific authentication: https://quarkus.io/guides/security#path-specific-authentication-mechanism.I've thought about it and IMHO it is totally safe to avoid failing the application if more than authentication mechanism with the same type is used - in reality it can only happen by mistake and documenting that in such cases unexpected authentication failures can happen is OK. It is impossible for example for
smallrye-jwt
to accidentally return a verifiedSecurityIdentity
whichquarkus-oidc/bearer
can also verify unless both share the same verification keys by pointing to Keycloak JWK endpoint, etc. The same applies to any combination of the same cred transport mechanisms - it will likely fail but can only succeed consistently if both mechanism share the verification related data.I'm not sure it is worth continue using a no-arg
HttpAuthenticationMechanism.getCredentialTransport
(it is deprecated in this PR) - it is just not a correct way to represent the current OIDC tenant expectation and one can easily enough workaround this restriction, example, register aCustomOidcAuthenticationMechanism
extendingOidcAuthenticationMechanism
but returning for exhybrid
as the transport value. IMHO a workaround specific around the combination of OIDC and MP JWT (#22437 => #22404 as a consequence).Note this PR has no tests yet and
getCredentialTransport(RoutingContext)
will returnUni
- for now I'd like to see if we can agree with Stuart in principle and if yes then I'll proceed with completing the PRCC @FroMage