java.lang.Object
com.irurueta.authserver.authorization.api.web.account.AccountController
All Implemented Interfaces:
AccountApi

@RestController public class AccountController extends Object implements AccountApi
Self-service account endpoints: registration, e-mail verification, password change and password reset. The paths, status codes and bodies are those of the contract apis/auth-server/rest-server/auth-server-api-v1.yaml, through the generated AccountApi. Failures are answered as RFC 9457 problem details by AccountExceptionHandler. No answer reveals whether an e-mail address belongs to an account.
  • Field Details

    • registerAccountUseCase

      private final RegisterAccountUseCase registerAccountUseCase
      Registers accounts.
    • verifyEmailUseCase

      private final VerifyEmailUseCase verifyEmailUseCase
      Verifies e-mail addresses.
    • changePasswordUseCase

      private final ChangePasswordUseCase changePasswordUseCase
      Changes the password of an authenticated account.
    • requestPasswordResetUseCase

      private final RequestPasswordResetUseCase requestPasswordResetUseCase
      Sends password reset links.
    • resetPasswordUseCase

      private final ResetPasswordUseCase resetPasswordUseCase
      Resets forgotten passwords.
    • accountRateLimiter

      private final AccountRateLimiter accountRateLimiter
      Limits the unauthenticated requests per client and per e-mail address.
  • Constructor Details

    • AccountController

      public AccountController()
  • Method Details

    • register

      public org.springframework.http.ResponseEntity<Void> register(RegisterRequest request)
      Registers an account. The answer is the same whether or not the address or the username was already taken.
      Specified by:
      register in interface AccountApi
      Parameters:
      request - registration data.
      Returns:
      202 Accepted.
    • verify

      public org.springframework.http.ResponseEntity<Void> verify(String token)
      Verifies an e-mail address.
      Specified by:
      verify in interface AccountApi
      Parameters:
      token - verification token received by e-mail.
      Returns:
      204 No Content.
    • changePassword

      public org.springframework.http.ResponseEntity<Void> changePassword(ChangePasswordRequest request)
      Changes the password of the authenticated account, the principal of the bearer token.
      Specified by:
      changePassword in interface AccountApi
      Parameters:
      request - current and new passwords.
      Returns:
      204 No Content.
    • requestPasswordReset

      public org.springframework.http.ResponseEntity<Void> requestPasswordReset(PasswordResetRequest request)
      Asks for a password reset link. The answer is the same whether or not the address belongs to an account, and even when the link cannot be delivered: only a registered address is ever mailed, so a delivery failure must not tell the caller that the address is registered (the use case has rolled back its token by then).
      Specified by:
      requestPasswordReset in interface AccountApi
      Parameters:
      request - e-mail address of the account.
      Returns:
      202 Accepted.
    • resetPassword

      public org.springframework.http.ResponseEntity<Void> resetPassword(ResetPasswordRequest request)
      Resets a forgotten password.
      Specified by:
      resetPassword in interface AccountApi
      Parameters:
      request - reset token and new password.
      Returns:
      204 No Content.
    • clientAddress

      private static String clientAddress()
      Returns the address of the client making the current request, the key of the rate limit. The generated interface carries only the contract's parameters, so the request is taken from the request context.
      Returns:
      the client address.
    • currentRequest

      private static jakarta.servlet.http.HttpServletRequest currentRequest()
      Returns the request being handled.
      Returns:
      the current HTTP request.