-
Notifications
You must be signed in to change notification settings - Fork 3k
OIDC: Add bearer token step up authentication #47445
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
OIDC: Add bearer token step up authentication #47445
Conversation
michalvavrik
commented
Apr 18, 2025
- closes: Support for OAuth2 Step-up authentication challenge protocol #46213
This comment has been minimized.
This comment has been minimized.
🙈 The PR is closed and the preview is expired. |
This comment has been minimized.
This comment has been minimized.
docs/src/main/asciidoc/security-oidc-bearer-token-authentication.adoc
Outdated
Show resolved
Hide resolved
extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/OidcBuildStep.java
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java
Outdated
Show resolved
Hide resolved
Hi @michalvavrik, thanks very much for agreeing to rework your original PR, it is close to being merged. I propose a couple of minor updates: always require setting ACRs with Have a look during the next couple of weeks please. Thanks |
This can't work with custom Jose4 Validator. How would you propagate information that |
@michalvavrik What if the user throws an exception from the validator, either |
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/AuthenticationContext.java
Show resolved
Hide resolved
That is not possible either, please have a look here https://bitbucket.org/b_c/jose4j/src/756257eb92352600d5dde08c2b8ed25db13a8952/src/main/java/org/jose4j/jwt/consumer/JwtConsumer.java#lines-447. Users may want it, but that's how Jose library is implemented. I think the only thing that would work is to throw
That's not the same, it is our own custom validator, yes, the exception is going to be silenced, but as we own the custom validator, we can just propagate the exception as field or whatever. It won't be nice, but it is not the same situation and is solvable. |
Yeah, you are right. Given that Jose4j accumulates results from all the validators it can be tricky to make it right. Hmm, but our custom validator is run as part of that Jose4j Validators iteration. I think in the short term we can just say, if you want to use But sure, let's not worry about it now, we can follow up with another PR for an annotation alternative later |
7d5f267
to
7e2c2df
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/AuthenticationContext.java
Outdated
Show resolved
Hide resolved
docs/src/main/asciidoc/security-oidc-bearer-token-authentication.adoc
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java
Outdated
Show resolved
Hide resolved
Hi Michal @michalvavrik, thanks for working hard on this enhancement, I've added quite a big number of comments but they are all mostly cosmetic, not major suggestions, primarily in the docs, with only a few in the code. IMHO it is getting closer, thanks for your patience. |
7e2c2df
to
f38953b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi Michal @michalvavrik, I think the Bearer access token related part is complete, thanks. There is one more thing that I believe we should deal with before merging. I believe we need to have some suggestion to users how they can enforce Step Up authentication without using annotations. Your PR to support the required claims as arrays was merged, so may be this PR can be rebased on top of it and we can try come up with some hack as suggested earlier to have the error propagated from our own custom Jose4j validator when acrs are not available ? May be just using |
I'll take care of it, sure, I believe there is a way to do it. |
@michalvavrik Perhaps, we can do
and throw it from our own Validator if the required claims map does not have it but also ask users to do it from their custom Validators when these checks may be more dynamic for a given tenant ? We can then convert it to |
@sberyozkin we can go to that, but I'll first present you with my solution, I am already done, just writing tests. |
@michalvavrik Sure |
533d5be
to
4581e84
Compare
This comment has been minimized.
This comment has been minimized.
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.
Perfect, thanks @michalvavrik
@michalvavrik Once this is released, please consider experimenting with some custom SPA which will do Keycloak login, be able to access some Quarkus endpoint and then be required to step up once it tries to access some path which requires a stronger authentication. It should be interesting to blog about |
This comment has been minimized.
This comment has been minimized.
@michalvavrik Hi Michal this test is a bit flaky right now, please have a look |
Basically, it behaves differently depending on the order in which tests are executed and passes on the second attempt because it is the only test run. The issue is not in mechanism added in this PR. I think I have fixed it by adding "reset" for the simple OIDC server, let's see. |
4581e84
to
735a043
Compare
Status for workflow
|
Status for workflow
|