I found one possibility, but I don't like it:
First of all I set the property quarkus.http.auth.proactive
to false
. In my ContainerRequestFilter (I already had one) I inject the JWTAuthContextInfo, clear there the public key content and set the public key location (if not already set). This leads to a reload of the file when parsing/validating the token.
Example code with a reload for every request:
application.properties
quarkus.http.auth.proactive=false
Code
@Priority(Priorities.AUTHORIZATION)
@Provider
public class RequestFilter implements ContainerRequestFilter {
@Inject
JWTParser jwtParser;
@Inject
JWTAuthContextInfo authContextInfo;
@Override
public void filter(final ContainerRequestContext requestContext) {
final var token = //... read token
clearKeyContent();
try {
return jsonWebToken = jwtParser.parse(token, authContextInfo);
} catch (final ParseException e) {
throw new ForbiddenException("unable to parse/validate token", e);
}
}
private void clearKeyContent() {
final var location = getKeyLocation(); // Returns the value of the MP/SmallRye property
if (location != null && !location.startsWith("http")) {
if (authContextInfo.getPublicKeyLocation() == null) {
authContextInfo.setPublicKeyLocation(location);
}
authContextInfo.setPublicKeyContent(null);
}
}
}