-
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
Option to try all OIDC JWK keys as fallback #42008
Conversation
Thanks for the effort, @c15yi, PR looks neat. |
In my case, the Do I understand your suggestion correctly, to try out the keys with I would create an option to check all keys, but only if there is no |
@sberyozkin updated the PR 🙂 |
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/JsonWebKeySet.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProvider.java
Outdated
Show resolved
Hide resolved
@c15yi, I guess something like this:
where Please think about it |
@sberyozkin, checking the signature twice is not optimal. What is the expected runtime duration for such check? I am just trying to understand the trade-off here. I have a few questions regarding your solution proposal.
Edit: When getting the keys from the jwks we would get all keys (for all algorithms) right? Or did you have some implementation in mind to select the correct algorithm based on the string jwt? |
@c15yi This is only a very rough prototype
As far as I understand, it could be the most effective, albeit the messy one. In this case, given 3 keys, you'll get at most 3 verifications in the worst case but only 1 in the best case. While with your last update, with 3 keys, in the worst case, you'll get 4 and in the best case 2 verifications. I've typed it and I think it is indeed not a big deal, so let's scrap my proposal, thanks for raising concerns about it. But it really should be a Map of algorithms to the list of keys. Each JWK must have an Thanks |
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/JsonWebKeySet.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/JsonWebKeySet.java
Outdated
Show resolved
Hide resolved
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/JsonWebKeySet.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/runtime/OidcProvider.java
Outdated
Show resolved
Hide resolved
Thanks for your work on this PR, @c15yi, it really looks good already, but I've asked for a few minor updates, thanks |
@c15yi FYI, I'll be going on PTO later today so we'll continue in mid of August, talk to you then |
@sberyozkin, in case you are still available, I just implemented your suggestions. Otherwise, have a great PTO, thanks for the reviews and talk to you then. |
Because our application is depending on this, would it be possible for someone else to take over the PR review, @sberyozkin? In the issue I created @pedroigor was mentioned for oidc, too. What do you think? |
...sions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DynamicVerificationKeyResolver.java
Outdated
Show resolved
Hide resolved
// if (newKey == null && tryAll && kid == null && thumbprint == null) { | ||
// LOG.debug("JWK is not available, neither 'kid' nor 'x5t#S256' nor 'x5t' token headers are set," | ||
// + " falling back to trying all available keys"); | ||
// newKey = jwks.findKeyInAllKeys(jws); // there is nothing to check the signature for in this method |
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.
Can you clarify this comment before uncommenting ?
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.
In the code of the DynamicVerificationKeyResolver
there is no JsonWebSignature
, but it need such object to perform the brute force algorithm on it with the different keys.
Therefore, I commented out the code, because it's not functional and I didn't see an easy solution to getting this to work there.
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.
@c15yi ok, a jose4j instance for verifying a signature can be built manually for this case with some custom basic resolver delegating to your new method, but I can take care of it later
@c15yi Sure, @pedroigor can definitely review. Your PR is nearly ready to go, couple of questions only there, and please squash it, keeping the main commit message only. Note though, I think it will only make it into 3.14, I'll be back by then: But I may be able to merge approve later today as well, once the last minor details are sorted out |
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.
I believe it's ready to go, dynamic resolver update can wait, no need to rush
This comment has been minimized.
This comment has been minimized.
39cbbfd
to
c6c24f5
Compare
bbdfb06
to
66b1f0c
Compare
@sberyozkin squashed the commits and added an explanation to your question on the |
This comment has been minimized.
This comment has been minimized.
66b1f0c
to
41de0f5
Compare
Status for workflow
|
@sberyozkin should this be merged? |
@geoand, @sberyozkin is currently on vacation and will be back mid of August. He approved it, but the pipelines failed, because I missed an unused import. Now everything should be ready I guess. |
Thanks. Let's wait for @sberyozkin to re-check |
Thanks @c15yi, @geoand, sorry but did not really have good options for merging it since heading to the airport on 27th July, but we still have a few days to have it merged and backported :-) |
No need to backport, it is just in time for 3.14 CR1 |
final CertChainPublicKeyResolver chainResolverFallback; | ||
|
||
public DynamicVerificationKeyResolver(OidcProviderClient client, OidcTenantConfig config) { | ||
this.client = client; | ||
this.tryAll = config.jwks.tryAll; |
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.
this variable is never used
@@ -115,6 +117,12 @@ public Uni<? extends VerificationKeyResolver> apply(JsonWebKeySet jwks) { | |||
newKey = jwks.getKeyWithoutKeyIdAndThumbprint("RSA"); | |||
} | |||
|
|||
// if (newKey == null && tryAll && kid == null && thumbprint == null) { |
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.
I think this is not useful to have this commented out code.
Instead of changing more logic to check multiple keys as fallback, which would mean bigger changes and also negatively impact performance, I added the option to specify a specific key as a fallback key in case no key could be determined.