Skip to content

Files

oauth2-jwk-redis

Relevant Information:

This module provides a JWKSource that supports key rotation strategies. RotateJwkSource is a JWKSource implementation that utilizes JWKSetCache to support key rotation.

In addition to the default Redis implementation in the project, it also supports local memory and Caffeine implementations.

The following code shows an example of how to configure the RotateJwkSource of the local in-memory key rotation strategy to provide support:

    @Bean
    public JWKSource<SecurityContext> jwkSource() {
        return new RotateJwkSource<>(new InMemoryJWKSetCache());
    }

RotateJwkSource also supports using Caffeine's key rotation strategy, which can be configured as follows:

    @Bean
    public JWKSource<SecurityContext> jwkSource() {
        return new RotateJwkSource<>(new CaffeineJWKSetCache());
    }

Let's test it out by visiting http://127.0.0.1:8070/client/article in your browser!

Relevant Articles: