Class DefaultOpenIdAuthenticationMapper

java.lang.Object
io.micronaut.security.oauth2.endpoint.token.response.DefaultOpenIdAuthenticationMapper
All Implemented Interfaces:
OpenIdAuthenticationMapper

@Singleton @Requires(configuration="io.micronaut.security.token.jwt") public class DefaultOpenIdAuthenticationMapper extends Object implements OpenIdAuthenticationMapper
The default implementation of OpenIdAuthenticationMapper that uses the subject claim for the username and populates the attributes with the non JWT standard claims. If an OpenIdAuthenticationMapper bean is created with a named qualifier that is the same name of the provider, that bean will be used instead of this one.
Since:
1.2.0
  • Constructor Details

    • DefaultOpenIdAuthenticationMapper

      public DefaultOpenIdAuthenticationMapper(OpenIdAdditionalClaimsConfiguration openIdAdditionalClaimsConfiguration, io.micronaut.security.config.AuthenticationModeConfiguration authenticationModeConfiguration)
      Default constructor.
      Parameters:
      openIdAdditionalClaimsConfiguration - The additional claims configuration
      authenticationModeConfiguration - Authentication Mode Configuration
  • Method Details

    • createAuthenticationResponse

      @NonNull public @NonNull org.reactivestreams.Publisher<io.micronaut.security.authentication.AuthenticationResponse> createAuthenticationResponse(String providerName, OpenIdTokenResponse tokenResponse, OpenIdClaims openIdClaims, @Nullable @Nullable State state)
      Specified by:
      createAuthenticationResponse in interface OpenIdAuthenticationMapper
      Parameters:
      providerName - The OpenID provider name
      tokenResponse - The token response
      openIdClaims - The OpenID claims
      state - The state of the response
      Returns:
      An authentication response
    • buildAttributes

      protected Map<String,Object> buildAttributes(String providerName, OpenIdTokenResponse tokenResponse, OpenIdClaims openIdClaims)
      Parameters:
      providerName - The OpenID provider name
      tokenResponse - The token response
      openIdClaims - The OpenID claims
      Returns:
      The attributes to set in the Authentication
    • getRoles

      protected List<String> getRoles(String providerName, OpenIdTokenResponse tokenResponse, OpenIdClaims openIdClaims)
      Parameters:
      providerName - The OpenID provider name
      tokenResponse - The token response
      openIdClaims - The OpenID claims
      Returns:
      The roles to set in the Authentication
    • getUsername

      protected String getUsername(String providerName, OpenIdTokenResponse tokenResponse, OpenIdClaims openIdClaims)
      Parameters:
      providerName - The OpenID provider name
      tokenResponse - The token response
      openIdClaims - The OpenID claims
      Returns:
      The username to set in the {Authentication