Class AccountController
java.lang.Object
com.irurueta.authserver.authorization.api.web.account.AccountController
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final AccountRateLimiterLimits the unauthenticated requests per client and per e-mail address.private final ChangePasswordUseCaseChanges the password of an authenticated account.private final RegisterAccountUseCaseRegisters accounts.private final RequestPasswordResetUseCaseSends password reset links.private final ResetPasswordUseCaseResets forgotten passwords.private final VerifyEmailUseCaseVerifies e-mail addresses.Fields inherited from interface com.irurueta.authserver.authorization.api.web.v1.generated.api.AccountApi
PATH_CHANGE_PASSWORD, PATH_REGISTER, PATH_REQUEST_PASSWORD_RESET, PATH_RESET_PASSWORD, PATH_VERIFY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Void> changePassword(ChangePasswordRequest request) Changes the password of the authenticated account, the principal of the bearer token.private static StringReturns the address of the client making the current request, the key of the rate limit.private static jakarta.servlet.http.HttpServletRequestReturns the request being handled.org.springframework.http.ResponseEntity<Void> register(RegisterRequest request) Registers an account.org.springframework.http.ResponseEntity<Void> requestPasswordReset(PasswordResetRequest request) Asks for a password reset link.org.springframework.http.ResponseEntity<Void> resetPassword(ResetPasswordRequest request) Resets a forgotten password.org.springframework.http.ResponseEntity<Void> Verifies an e-mail address.
-
Field Details
-
registerAccountUseCase
Registers accounts. -
verifyEmailUseCase
Verifies e-mail addresses. -
changePasswordUseCase
Changes the password of an authenticated account. -
requestPasswordResetUseCase
Sends password reset links. -
resetPasswordUseCase
Resets forgotten passwords. -
accountRateLimiter
Limits the unauthenticated requests per client and per e-mail address.
-
-
Constructor Details
-
AccountController
public AccountController()
-
-
Method Details
-
register
Registers an account. The answer is the same whether or not the address or the username was already taken.- Specified by:
registerin interfaceAccountApi- Parameters:
request- registration data.- Returns:
202 Accepted.
-
verify
Verifies an e-mail address.- Specified by:
verifyin interfaceAccountApi- Parameters:
token- verification token received by e-mail.- Returns:
204 No Content.
-
changePassword
Changes the password of the authenticated account, the principal of the bearer token.- Specified by:
changePasswordin interfaceAccountApi- 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:
requestPasswordResetin interfaceAccountApi- Parameters:
request- e-mail address of the account.- Returns:
202 Accepted.
-
resetPassword
Resets a forgotten password.- Specified by:
resetPasswordin interfaceAccountApi- Parameters:
request- reset token and new password.- Returns:
204 No Content.
-
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.
-