Skip to content

Commit a451cdd

Browse files
authored
JwtProvider expected audience is no longer mandatory (#10778)
JwtProvider expected audience is no longer mandatory Signed-off-by: David Kral <[email protected]>
1 parent c319b79 commit a451cdd

File tree

1 file changed

+6
-4
lines changed
  • security/providers/jwt/src/main/java/io/helidon/security/providers/jwt

1 file changed

+6
-4
lines changed

security/providers/jwt/src/main/java/io/helidon/security/providers/jwt/JwtProvider.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ private AuthenticationResponse authenticateToken(String token) {
168168
if (errors.isValid()) {
169169
Jwt jwt = signedJwt.getJwt();
170170
// perform all validations, including expected audience verification
171-
JwtValidator jwtValidator = JwtValidator.builder()
171+
JwtValidator.Builder jwtValidatorBuilder = JwtValidator.builder()
172172
.addDefaultTimeValidators()
173173
.addCriticalValidator()
174-
.addUserPrincipalValidator()
175-
.addAudienceValidator(expectedAudience)
176-
.build();
174+
.addUserPrincipalValidator();
175+
if (expectedAudience != null) {
176+
jwtValidatorBuilder.addAudienceValidator(expectedAudience);
177+
}
178+
JwtValidator jwtValidator = jwtValidatorBuilder.build();
177179
Errors validate = jwtValidator.validate(jwt);
178180
if (validate.isValid()) {
179181
return AuthenticationResponse.success(buildSubject(jwt, signedJwt));

0 commit comments

Comments
 (0)