Class DefaultOpenIdAuthenticationMapper

  • All Implemented Interfaces:
    OpenIdAuthenticationMapper

    @Singleton
    @Requires(configuration="io.micronaut.security.token.jwt")
    public class DefaultOpenIdAuthenticationMapper
    extends java.lang.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 Detail

      • DefaultOpenIdAuthenticationMapper

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

      • createAuthenticationResponse

        @NonNull
        public io.micronaut.security.authentication.AuthenticationResponse createAuthenticationResponse​(java.lang.String providerName,
                                                                                                        OpenIdTokenResponse tokenResponse,
                                                                                                        OpenIdClaims openIdClaims,
                                                                                                        @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 java.util.Map<java.lang.String,​java.lang.Object> buildAttributes​(java.lang.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 java.util.List<java.lang.String> getRoles​(java.lang.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 java.lang.String getUsername​(java.lang.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