Class LegacyImplicitAuthenticationProvider

java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.LegacyImplicitAuthenticationProvider
All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider

public class LegacyImplicitAuthenticationProvider extends Object implements org.springframework.security.authentication.AuthenticationProvider
Grants the legacy implicit request: after checking the client, its redirect URI, the user, the multi-factor policy, the state and the scopes, it issues an access token (never a refresh token) through the token generator, stores the authorization (so the token can be introspected and revoked) and returns it for the response handler.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Applies the multi-factor policy.
    private final org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService
    Stores the authorization behind the token.
    static final org.springframework.security.oauth2.core.AuthorizationGrantType
    Grant type recorded for the tokens of the flow; the framework has no constant for it.
    private final Duration
    Longest lifetime of the tokens of the flow.
    private final org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
    Finds the client.
    private final org.springframework.security.oauth2.server.authorization.token.OAuth2TokenGenerator<? extends org.springframework.security.oauth2.core.OAuth2Token>
    Generates the access token, with the claims of the other flows.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.core.Authentication
    authenticate(org.springframework.security.core.Authentication authentication)
    Grants or refuses the request.
    issue(LegacyImplicitAuthorizationRequestToken request, org.springframework.security.oauth2.server.authorization.client.RegisteredClient client, org.springframework.security.core.Authentication user, Set<String> scopes)
    Issues and stores the access token.
    private static org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationException
    Builds a refusal that is answered with 400, never redirected, because the redirect URI is not trusted yet or the user cannot be sent anywhere.
    boolean
    supports(Class<?> authentication)
    Tells which requests this provider handles.
    private org.springframework.security.oauth2.server.authorization.client.RegisteredClient
    withCappedLifetime(org.springframework.security.oauth2.server.authorization.client.RegisteredClient client)
    Copies the client with the lifetime of its access tokens limited to the maximum of the flow.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • IMPLICIT

      public static final org.springframework.security.oauth2.core.AuthorizationGrantType IMPLICIT
      Grant type recorded for the tokens of the flow; the framework has no constant for it.
    • registeredClients

      private final org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository registeredClients
      Finds the client.
    • authorizationService

      private final org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService authorizationService
      Stores the authorization behind the token.
    • tokenGenerator

      private final org.springframework.security.oauth2.server.authorization.token.OAuth2TokenGenerator<? extends org.springframework.security.oauth2.core.OAuth2Token> tokenGenerator
      Generates the access token, with the claims of the other flows.
    • authorizationManager

      private final MfaAuthorizationManager authorizationManager
      Applies the multi-factor policy.
    • maxAccessTokenTtl

      private final Duration maxAccessTokenTtl
      Longest lifetime of the tokens of the flow.
  • Constructor Details

    • LegacyImplicitAuthenticationProvider

      public LegacyImplicitAuthenticationProvider()
  • Method Details

    • authenticate

      public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationException
      Grants or refuses the request.
      Specified by:
      authenticate in interface org.springframework.security.authentication.AuthenticationProvider
      Parameters:
      authentication - the request, a LegacyImplicitAuthorizationRequestToken.
      Returns:
      the access token, or the error that must be sent in the fragment of the redirect URI.
      Throws:
      org.springframework.security.core.AuthenticationException - unsupported_response_type or unauthorized_client when the client is unknown or may not use the flow, invalid_request when the redirect URI is missing or not registered or the user is not signed in (none of them redirects), SecondFactorRequiredException when the user owes a second factor, or server_error when no token can be generated.
    • supports

      public boolean supports(Class<?> authentication)
      Tells which requests this provider handles.
      Specified by:
      supports in interface org.springframework.security.authentication.AuthenticationProvider
      Parameters:
      authentication - the type of the request.
      Returns:
      true for a request of the legacy flow.
    • issue

      private LegacyImplicitAccessTokenToken issue(LegacyImplicitAuthorizationRequestToken request, org.springframework.security.oauth2.server.authorization.client.RegisteredClient client, org.springframework.security.core.Authentication user, Set<String> scopes)
      Issues and stores the access token.
      Parameters:
      request - the request.
      client - the client.
      user - the signed-in user.
      scopes - the scopes granted.
      Returns:
      the result.
    • withCappedLifetime

      private org.springframework.security.oauth2.server.authorization.client.RegisteredClient withCappedLifetime(org.springframework.security.oauth2.server.authorization.client.RegisteredClient client)
      Copies the client with the lifetime of its access tokens limited to the maximum of the flow.
      Parameters:
      client - the client.
      Returns:
      the client with the lifetime min(client, maximum).
    • refused

      private static org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationException refused(String code)
      Builds a refusal that is answered with 400, never redirected, because the redirect URI is not trusted yet or the user cannot be sent anywhere.
      Parameters:
      code - error code.
      Returns:
      the exception.