java.lang.Object
com.irurueta.authserver.serviceclient.infrastructure.resourceserver.OAuth2ClientConfiguration

@Configuration(proxyBeanMethods=false) @EnableConfigurationProperties({ResourceServerProperties.class,ServiceClientAuthProperties.class,ServiceClientKeyProperties.class}) public class OAuth2ClientConfiguration extends Object
The OAuth2 client of the service client: its registrations, the authorized client manager that caches the access tokens and renews them shortly before they expire, and the documents client that sends them. Nothing here depends on a profile: every setting has a default, and a mutual TLS or private_key_jwt setup only fails when its key or bundle is missing at the moment it is needed.
  • Constructor Details

    • OAuth2ClientConfiguration

      public OAuth2ClientConfiguration()
  • Method Details

    • serviceClientRegistrations

      @Bean org.springframework.security.oauth2.client.registration.ClientRegistrationRepository serviceClientRegistrations(ServiceClientRegistrationMapper mapper, ServiceClientAuthProperties properties)
      Registrations of the client credentials and token exchange grants.
      Parameters:
      mapper - builds the registrations.
      properties - settings of the service client.
      Returns:
      the repository.
    • serviceClientAuthorizedClients

      @Bean org.springframework.security.oauth2.client.OAuth2AuthorizedClientService serviceClientAuthorizedClients(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository registrations)
      The cache of the authorized clients, so a token is reused while it is valid.
      Parameters:
      registrations - the registrations.
      Returns:
      the service.
    • serviceClientAuthorizedClientManager

      @Bean org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager serviceClientAuthorizedClientManager(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository registrations, org.springframework.security.oauth2.client.OAuth2AuthorizedClientService clients, TokenEndpointClients tokenClients, PrincipalMapper principalMapper, ServiceClientAuthProperties properties)
      The authorized client manager. It works without a servlet request, as there is none in the CLI. A cached token is renewed once less than service-client.auth.refresh-before of its life is left.
      Parameters:
      registrations - the registrations.
      clients - the cache of the authorized clients.
      tokenClients - the clients of the token endpoint.
      principalMapper - builds the principal of the service client.
      properties - settings of the service client.
      Returns:
      the manager.
    • serviceClientDPoPProofs

      @Bean @ConditionalOnProperty(prefix="service-client.auth", name="dpop", havingValue="true") DPoPProofs serviceClientDPoPProofs() throws com.nimbusds.jose.JOSEException
      Generates the key pair that signs the DPoP proofs, for the life of the process. Present only when service-client.auth.dpop is true.
      Returns:
      the proof creator.
      Throws:
      com.nimbusds.jose.JOSEException - if the key cannot be generated.
    • serviceClientDocumentsApi

      @Bean DocumentsApi serviceClientDocumentsApi(DocumentsApis documentsApis, PrincipalMapper principalMapper, ServiceClientAuthProperties properties)
      The documents client of the service client itself, whose requests carry the client credentials token.
      Parameters:
      documentsApis - builds documents clients.
      principalMapper - builds the principal of the service client.
      properties - settings of the service client.
      Returns:
      the documents client.