RANGER-5533:Verify JWT Issuer Claims if present#901
Open
ChinmayHegde24 wants to merge 1 commit intoapache:masterfrom
Open
RANGER-5533:Verify JWT Issuer Claims if present#901ChinmayHegde24 wants to merge 1 commit intoapache:masterfrom
ChinmayHegde24 wants to merge 1 commit intoapache:masterfrom
Conversation
kumaab
reviewed
Mar 31, 2026
| * @param jwtToken the JWT token from which the JWT issuer will be obtained | ||
| * @return true if an expected issuer is present, otherwise false | ||
| */ | ||
| protected boolean validateIssuer(final SignedJWT jwtToken) { |
Contributor
There was a problem hiding this comment.
Instead of adding a standalone validateIssuer() method, consider using Nimbus's DefaultJWTClaimsVerifier, which would consolidate issuer, audience, and expiration checks in one place:
JWTClaimsSet.Builder exactMatchBuilder = new JWTClaimsSet.Builder();
String issuer = config.getProperty(KEY_JWT_ISSUER);
if (StringUtils.isNotBlank(issuer)) {
exactMatchBuilder.issuer(issuer);
}
Set<String> acceptedAudiences = null;
String audiencesStr = config.getProperty(KEY_JWT_AUDIENCES);
if (StringUtils.isNotBlank(audiencesStr)) {
acceptedAudiences = new HashSet<>(Arrays.asList(audiencesStr.split(",")));
}
claimsVerifier = new DefaultJWTClaimsVerifier<>(acceptedAudiences, exactMatchBuilder.build(), null, null);
claimsVerifier.verify(jwtToken.getJWTClaimsSet(), null);This would replace all three of validateExpiration(), validateAudiences(), and the proposed validateIssuer() with a single, well-tested library call. It also gets clock skew handling for free (the verifier has a configurable skew, defaulting to 60 seconds).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support for validating the iss (issuer) claim in JWT has been added as part of this PR.