-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow token verification with user info when no introspection endpoint is available #29715
Allow token verification with user info when no introspection endpoint is available #29715
Conversation
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
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/OidcProvider.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
Thanks Michal @michalvavrik for giving it a try - it does look quite good, I've left a good number of comments, but nothing major really, for example if it is a token in JWT format then the provider must be able to verify this token in a standard way, by providing the verification keys or having an introspection endpoint. Re the bearer token vs access token, the bearer tokens are always the access tokens, that is true, but if we have Code Flow then we get ID token (always JWT) and access token - which can be opaque as with Google/Azure/etc, so it would be more flexible to have Cheers |
afab697
to
34d9ada
Compare
Thank you @sberyozkin , I've learned a lot from your comments and adjusted PR accordingly. |
This comment has been minimized.
This comment has been minimized.
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
...ation-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/CodeFlowUserInfoResource.java
Outdated
Show resolved
Hide resolved
integration-tests/oidc-wiremock/src/main/resources/application.properties
Outdated
Show resolved
Hide resolved
integration-tests/oidc-wiremock/src/main/resources/application.properties
Outdated
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
bd43468
to
a9470dc
Compare
This comment has been minimized.
This comment has been minimized.
|
a9470dc
to
48e0ea8
Compare
This comment has been minimized.
This comment has been minimized.
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
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/OidcTenantConfig.java
Outdated
Show resolved
Hide resolved
Hi @michalvavrik I've left another 3 comments - I know it can be time consuming. This is how I work with OIDC issues myself unless they are really trivial, I go in multiple iterations to prepare a single PR, do it once, then it is always the case of being in real doubt if I did it right, I keep renaming things, etc. It is a very important piece of Quarkus security so we just need to be as precise as possible. |
48e0ea8
to
cb095d4
Compare
Np @sberyozkin , let's do as many iterations as necessary. I think PR looks better after changes and I appreciate your help. |
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.
Thanks @michalvavrik, nice work.
I've been thinking, OK, what happens now if someone steals the token and posts it and UserInfo is returned and hence the access is allowed.... But then I've realized the same risk exists with any bearer token authentication, if the token is stolen.
This is why the use of HTTPS, MTLS is needed, other measures like limiting the number of times the token can be used, do not give it 1 month lifetime, etc that can help.
This also made me think we'd need to consider to have an optional request token cache, similarly to what we have with UserInfo/TokenIntrospection, where the users can enforce for example a single (limited - number of times, age) token use only - something that OIDC providers should also be doing - I'll open an enhancement request to discuss it further
And which is why we have made it a bit harder to configure in this particular case, not only require users to say the userinfo is needed but also to approve the indirect token verification with an extra flag |
@pedroigor Hey Pedro, I'm intending to merge early next week, LGTM, but if you have any comments let us know please. |
For the future work: #29777 |
follow up to quarkusio#29715 I think previous condition was typo and it worked as by default `allow-opaque-token-introspection` is set to true (which is going to change in the future). We should only allow empty introspection result if that's a way how user info verification says "verification has been successful".
follow up to quarkusio#29715 I think previous condition was typo and it worked as by default `allow-opaque-token-introspection` is set to true (which is going to change in the future). We should only allow empty introspection result if that's a way how user info verification says "verification has been successful".
closes: #20911
Makes it possible to use user-info endpoint with providers that does not provide introspection endpoint for Bearer token indirect verification, so that providers like GitHub may be used with service endpoints. I tested it with real GitHub application (not mock).