[feat][authentication] Add JWKS support for AuthenticationProviderToken - #18336
[feat][authentication] Add JWKS support for AuthenticationProviderToken#18336nodece wants to merge 1 commit into
Conversation
|
/pulsarbot rerun-failure-checks |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18336 +/- ##
============================================
- Coverage 50.05% 46.48% -3.58%
+ Complexity 11024 10441 -583
============================================
Files 703 703
Lines 68814 68816 +2
Branches 7378 7377 -1
============================================
- Hits 34446 31986 -2460
- Misses 30621 33219 +2598
+ Partials 3747 3611 -136
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
rdhabalia
left a comment
There was a problem hiding this comment.
this PR is adding new feature and it should go through PIP.
+1 @nodece Could you please start a proposal for this change? |
Thanks. Let me make a PIP. |
| if (bytes == null || bytes.length == 0) { | ||
| throw new IOException("invalid JWKs data"); | ||
| } | ||
| json = new String(AuthTokenUtils.readKeyFromUrl(data), StandardCharsets.UTF_8); |
There was a problem hiding this comment.
Why call this function AuthTokenUtils.readKeyFromUrl(data) again?
There was a problem hiding this comment.
Good catch. Here should be bytes.
| return AuthTokenUtils.decodePublicKey(validationKey, publicKeyAlg); | ||
| } else { | ||
| throw new IOException("No secret key was provided for token authentication"); | ||
| return null; |
There was a problem hiding this comment.
I don't think it's the third case, it seems like it should be considered adding it to the if branch of the readKeyFromUrl, which is essentially where the public key is read (file, string or an http host)
There was a problem hiding this comment.
See lines 158-162.
This method just gets the public or secret key. When returns null, we read the JWKS data.
| } | ||
| } | ||
|
|
||
| private static final class TokenSigningKeyResolver implements SigningKeyResolver { |
There was a problem hiding this comment.
I think the TokenSigningKeyResolver should be called in the readKeyFromUrl function
There was a problem hiding this comment.
See line 491.
data is a file path or data-url.
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
9dfe47c to
7ed2770
Compare
|
The pr had no activity for 30 days, mark with Stale label. |
|
Ping @michaeljmarshall, could you track this PR? |
| String kid = node.get("kid").textValue(); | ||
| KeyFactory kf; | ||
| // Reference from: | ||
| // https://github.com/auth0/jwks-rsa-java/blob/0.21.2/src/main/java/com/auth0/jwk/Jwk.java#L176 |
There was a problem hiding this comment.
Is there a reason we cannot use this library directly instead of copying the code here?
There was a problem hiding this comment.
We just use the Jwk class, and don't want to introduce the other dependency.
There was a problem hiding this comment.
The license might require that we change this PR: https://github.com/auth0/jwks-rsa-java/blob/0.21.2/LICENSE.
@dave2wave - are you able to provide any guidance on the licensing aspect here? Thanks!
michaeljmarshall
left a comment
There was a problem hiding this comment.
#8152 asks for support to rotate public keys and to load new public keys "on the fly". This PR appears to add support for loading multiple public keys on start up, but it does not provide support for rotation or dynamic loading. Is that correct? If so, I don't think we should say this PR fixes #8152.
You are right, I think we can listener to the file changes. |
michaeljmarshall
left a comment
There was a problem hiding this comment.
Requesting changes while we determine the licensing portion of this PR.
| String kid = node.get("kid").textValue(); | ||
| KeyFactory kf; | ||
| // Reference from: | ||
| // https://github.com/auth0/jwks-rsa-java/blob/0.21.2/src/main/java/com/auth0/jwk/Jwk.java#L176 |
There was a problem hiding this comment.
The license might require that we change this PR: https://github.com/auth0/jwks-rsa-java/blob/0.21.2/LICENSE.
@dave2wave - are you able to provide any guidance on the licensing aspect here? Thanks!
|
The pr had no activity for 30 days, mark with Stale label. |
|
Closing this PR with #19849. |
|
Use #22215 instead of this PR. |
Motivation
Add JWKS support for AuthenticationProviderToken.
Modifications
tokenKeySetconfig to provide the JWKS supportVerifying this change
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: nodece#11