Skip to content

Commit 2d78232

Browse files
committed
ease override of number of JWS refresh attempts
1 parent 1d57dd9 commit 2d78232

File tree

1 file changed

+10
-2
lines changed
  • security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks

1 file changed

+10
-2
lines changed

security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignature.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
public class JwksSignature implements SignatureConfiguration {
5959

6060
private static final Logger LOG = LoggerFactory.getLogger(JwksSignature.class);
61-
private static final int REFRESH_JWKS_ATTEMPTS = 1;
61+
public static final int DEFAULT_REFRESH_JWKS_ATTEMPTS = 1;
6262

6363
@Nullable
6464
private JWKSet jwkSet;
@@ -129,7 +129,7 @@ public boolean supports(JWSAlgorithm algorithm) {
129129
*/
130130
@Override
131131
public boolean verify(SignedJWT jwt) throws JOSEException {
132-
List<JWK> matches = matches(jwt, getJWKSet().orElse(null), REFRESH_JWKS_ATTEMPTS);
132+
List<JWK> matches = matches(jwt, getJWKSet().orElse(null), getRefreshJwksAttempts());
133133
if (LOG.isDebugEnabled()) {
134134
LOG.debug("Found {} matching JWKs", matches.size());
135135
}
@@ -247,4 +247,12 @@ protected boolean verify(List<JWK> matches, SignedJWT jwt) {
247247
}
248248
});
249249
}
250+
251+
/**
252+
* Returns the number of attempts to refresh the cached JWKS.
253+
* @return Number of attempts to refresh the cached JWKS.
254+
*/
255+
public int getRefreshJwksAttempts() {
256+
return DEFAULT_REFRESH_JWKS_ATTEMPTS;
257+
}
250258
}

0 commit comments

Comments
 (0)