Class JwksUriSignatureFactory

java.lang.Object
io.micronaut.security.oauth2.client.JwksUriSignatureFactory

@Factory @Internal public class JwksUriSignatureFactory extends Object
Factory to create ReactiveJwksSignature beans for the OpenIdProviderMetadata.getJwksUri() of OpenID clients.

The beans are only created for the AuthenticationMode.IDTOKEN authentication mode, where the ID token issued by the provider is the request credential. In any other authentication mode, tokens signed by the provider's keys, such as ID tokens issued to other clients, must not authenticate requests. The ID token obtained during the authorization code flow is validated against the provider's JWKS independently of these beans. No bean is created for a disabled OAuth 2.0 client.

The key set of a provider is bound to the issuer of that provider (see JwksSignatureConfiguration.getIssuer()), so that a token whose iss claim names one provider cannot be verified with the keys of another provider.

Since:
1.3.0
Author:
Sergio del Amo
  • Constructor Details

    • JwksUriSignatureFactory

      public JwksUriSignatureFactory(io.micronaut.context.BeanContext beanContext)
      Parameters:
      beanContext - The bean context
  • Method Details

    • createJwksSignatureConfiguration

      @Requires(property="micronaut.security.authentication",value="idtoken") @Requires(condition=OauthClientEnabledCondition.class) @EachBean(OpenIdClientConfiguration.class) public JwksSignatureConfiguration createJwksSignatureConfiguration(@Parameter OpenIdClientConfiguration openIdClientConfiguration, @Parameter io.micronaut.context.BeanProvider<DefaultOpenIdProviderMetadata> openIdProviderMetadata, @Named("blocking") ExecutorService executorService, JwksClientConfiguration jwksClientConfiguration)
      Creates a JwksSignatureConfiguration for the jwks_uri exposed via the OpenID configuration of the client. The configuration is created for every enabled OpenID client, even if the OpenID configuration could not be fetched at startup, so that an unreachable provider never leaves the application without signature configurations. The jwks_uri and the issuer come from the provider metadata: the one already created at startup, or else one resolved on the blocking executor, see OpenIdProviderJwksSignatureConfiguration.
      Parameters:
      openIdClientConfiguration - The OpenID client configuration
      openIdProviderMetadata - The open id provider metadata
      executorService - Executor used to resolve the provider metadata when it was not created at startup
      jwksClientConfiguration - JWKS client configuration, whose failure back-off bounds how often the provider metadata is requested after a failure
      Returns:
      a JwksSignatureConfiguration pointed to the jwks_uri exposed via OpenID configuration and bound to the issuer of the OpenID client