-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9891 from sberyozkin/refresh_jwk
OIDC JWK refresh support
- Loading branch information
Showing
15 changed files
with
445 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
35 changes: 35 additions & 0 deletions
35
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/JwkSetRefreshHandler.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.quarkus.oidc.runtime; | ||
|
||
import java.time.Duration; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.ext.auth.oauth2.OAuth2Auth; | ||
|
||
public class JwkSetRefreshHandler implements Handler<String> { | ||
private static final Logger LOG = Logger.getLogger(JwkSetRefreshHandler.class); | ||
private OAuth2Auth auth; | ||
private volatile long lastForcedRefreshTime; | ||
private long forcedJwksRefreshIntervalMilliSecs; | ||
|
||
public JwkSetRefreshHandler(OAuth2Auth auth, Duration forcedJwksRefreshInterval) { | ||
this.auth = auth; | ||
this.forcedJwksRefreshIntervalMilliSecs = forcedJwksRefreshInterval.toMillis(); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Override | ||
public void handle(String kid) { | ||
final long now = System.currentTimeMillis(); | ||
if (now > lastForcedRefreshTime + forcedJwksRefreshIntervalMilliSecs) { | ||
lastForcedRefreshTime = now; | ||
LOG.debugf("No JWK with %s key id is available, trying to refresh the JWK set", kid); | ||
auth.loadJWK(res -> { | ||
if (res.failed()) { | ||
LOG.debugf("Failed to refresh the JWK set: %s", res.cause()); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.