Class FederatedAccountResolver

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.FederatedAccountResolver

public class FederatedAccountResolver extends Object
Finds the local account of a sign-in with an external provider and refuses it unless that account may sign in.

The use case finds, links or provisions the account and refuses a disabled one before it links anything; the account is then loaded through the status-checking user service as well (the rules of AccountStatusUserDetailsService: a disabled, locked or expired account is refused, exactly as the password and passkey sign-ins refuse it). Every refusal is the same access_denied error, which the login chain turns into the generic failure of the login page, so the answer never says whether an account exists or why it was refused.

When the signed-in user asked to link this provider (PendingIdentityLinks), the identity is linked to that account through LinkIdentityUseCase instead: nothing is resolved by e-mail address or provisioned, and an identity that belongs to another account is refused with LINK_REFUSED, which the failure handler sends back to the identities page.

  • Field Details

    • REFUSED

      static final String REFUSED
      Error description of every refusal.
      See Also:
    • resolveFederatedLoginUseCase

      private final ResolveFederatedLoginUseCase resolveFederatedLoginUseCase
      Use case that finds, links or provisions the account.
    • accountStatusUserDetailsService

      private final org.springframework.security.core.userdetails.UserDetailsService accountStatusUserDetailsService
      Loads the account, refusing one that may not sign in.
    • linkIdentityUseCase

      private final LinkIdentityUseCase linkIdentityUseCase
      Use case that links an identity to the signed-in account.
  • Constructor Details

    • FederatedAccountResolver

      public FederatedAccountResolver()
  • Method Details

    • resolve

      public org.springframework.security.core.userdetails.UserDetails resolve(IdentityProvider provider, String subject, String email, boolean emailVerified)
      Resolves a sign-in.
      Parameters:
      provider - the provider that authenticated the user.
      subject - the provider's stable identifier of the user.
      email - e-mail address the provider reported, or null.
      emailVerified - whether the provider vouches for the address.
      Returns:
      the local account, which may sign in; for a link, the signed-in account.
      Throws:
      org.springframework.security.oauth2.core.OAuth2AuthenticationException - if the sign-in is refused: the provider did not verify the address, the address belongs to an unverified account, or the account is disabled, locked or expired; or if a link is refused because the identity belongs to another account.
    • link

      private org.springframework.security.core.userdetails.UserDetails link(PendingIdentityLink link, IdentityProvider provider, String subject, String email)
      Links an identity to the signed-in account that asked for it.
      Parameters:
      link - the link marker.
      provider - the provider that authenticated the user.
      subject - the provider's stable identifier of the user.
      email - e-mail address the provider reported, or null.
      Returns:
      the signed-in account.
      Throws:
      org.springframework.security.oauth2.core.OAuth2AuthenticationException - if the identity belongs to another account, or the account may no longer sign in.