Skip to content

Commit

Permalink
Change the null check right after the jwtparserbuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Aug 25, 2023
1 parent a805843 commit 4b406c5
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public HTTPJwtAuthenticator(final Settings settings, final Path configPath) {
super();

String signingKey = settings.get("signing_key");

JwtParserBuilder jwtParserBuilder = KeyUtils.createJwtParserBuilderFromSigningKey(signingKey, log);

jwtUrlParameter = settings.get("jwt_url_parameter");
jwtHeaderName = settings.get("jwt_header", HttpHeaders.AUTHORIZATION);
isDefaultAuthHeader = HttpHeaders.AUTHORIZATION.equalsIgnoreCase(jwtHeaderName);
Expand All @@ -69,18 +66,19 @@ public HTTPJwtAuthenticator(final Settings settings, final Path configPath) {
requireAudience = settings.get("required_audience");
requireIssuer = settings.get("required_issuer");

if (requireAudience != null) {
jwtParserBuilder = jwtParserBuilder.require("aud", requireAudience);
}
JwtParserBuilder jwtParserBuilder = KeyUtils.createJwtParserBuilderFromSigningKey(signingKey, log);
if (jwtParserBuilder == null) {
jwtParser = null;
} else {
if (requireAudience != null) {
jwtParserBuilder = jwtParserBuilder.require("aud", requireAudience);
}

if (requireIssuer != null) {
jwtParserBuilder = jwtParserBuilder.require("iss", requireIssuer);
}
if (requireIssuer != null) {
jwtParserBuilder = jwtParserBuilder.require("iss", requireIssuer);
}

if (jwtParserBuilder != null) {
jwtParser = jwtParserBuilder.build();
} else {
jwtParser = null;
}
}

Expand Down

0 comments on commit 4b406c5

Please sign in to comment.