Class DatabaseJwkSourceConfiguration

java.lang.Object
com.irurueta.authserver.authorization.infrastructure.keys.DatabaseJwkSourceConfiguration

@Configuration(proxyBeanMethods=false) public class DatabaseJwkSourceConfiguration extends Object
Serves the signing keys kept by the key use cases. Two views of them exist on purpose: the public JWKS lists the active key, the next key and the still-valid retired keys, whereas the JwtEncoder only ever sees the single active key with its private half, so signing never has to choose between several keys. The conversion of the stored keys into JSON Web Keys belongs to the SigningKeyJwkMapper.
  • Constructor Details

    • DatabaseJwkSourceConfiguration

      public DatabaseJwkSourceConfiguration()
  • Method Details

    • publishedJwkSet

      @Bean public CachedJwkSet publishedJwkSet(PublishedSigningKeysUseCase published, SigningKeyJwkMapper mapper, Clock clock, @Value("${authserver.keys.jwks-cache-ttl:PT30S}") Duration ttl)
      Creates the cached set of public keys.
      Parameters:
      published - use case that finds the keys to publish.
      mapper - maps the keys onto JSON Web Keys.
      clock - source of the current time.
      ttl - how long the set is kept (authserver.keys.jwks-cache-ttl, default 30 seconds).
      Returns:
      the cache; call CachedJwkSet.refresh() after a rotation.
    • signingJwkSet

      @Bean public CachedJwkSet signingJwkSet(ActiveSigningKeyUseCase active, SigningKeyJwkMapper mapper, Clock clock, @Value("${authserver.keys.jwks-cache-ttl:PT30S}") Duration ttl)
      Creates the cached set holding only the active key, with its private half.
      Parameters:
      active - use case that finds the active key.
      mapper - maps the key onto a JSON Web Key, decrypting its private half.
      clock - source of the current time.
      ttl - how long the set is kept (authserver.keys.jwks-cache-ttl, default 30 seconds).
      Returns:
      the cache; call CachedJwkSet.refresh() after a rotation.
    • jwkSource

      @Bean public com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext> jwkSource(@Qualifier("publishedJwkSet") CachedJwkSet publishedJwkSet)
      Creates the source of the public JWKS. It never holds a private key.
      Parameters:
      publishedJwkSet - the cached public keys.
      Returns:
      the source.
    • jwtEncoder

      @Bean public org.springframework.security.oauth2.jwt.JwtEncoder jwtEncoder(@Qualifier("signingJwkSet") CachedJwkSet signingJwkSet)
      Creates the encoder that signs tokens with the active key.
      Parameters:
      signingJwkSet - the cached active key.
      Returns:
      the encoder.