Class PhoneController
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.PhoneController
- All Implemented Interfaces:
PhoneApi
Shows, enrols, verifies and removes the phone number of the authenticated account, the number the SMS codes go to.
The paths, status codes and bodies are those of the contract
apis/auth-server/rest-server/
auth-server-api-v1.yaml, through the generated PhoneApi; failures are answered by
OttExceptionHandler. Starting an enrolment and verifying it spend SMS budget and guess a code, so both are
limited per client address and per account (OttRateLimiter). Starting an enrolment (which may replace the
verified phone, a second factor) and removing the phone need a recent multi-factor sign-in while the account has a
confirmed second factor (StepUpGuard).-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringPrefix of the rate-limit key of an account, which cannot clash with a user name typed in a sign-in form.private final ConfirmPhoneUseCaseConfirms an enrolment.private final CurrentAccountResolverResolves the account of the request.private final FindUserPhoneUseCaseFinds the verified phone of the account.private final PhoneDtoMapperMaps the results onto the contract's DTOs.private final OttRateLimiterLimits the requests.private final RemovePhoneUseCaseRemoves the phone.private final jakarta.servlet.http.HttpServletRequestThe current request, injected as a thread-bound proxy, which tells the address of the client.private final StartPhoneEnrolmentUseCaseStarts an enrolment.private final StepUpGuardRequires a recent multi-factor sign-in before the phone is replaced or removed.Fields inherited from interface com.irurueta.authserver.authorization.api.web.v1.generated.api.PhoneApi
PATH_GET_PHONE, PATH_REMOVE_PHONE, PATH_START_PHONE_ENROLMENT, PATH_VERIFY_PHONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<PhoneResponse> getPhone()Gets the verified phone, masked.org.springframework.http.ResponseEntity<Void> Removes the phone and any pending verification.org.springframework.http.ResponseEntity<PhoneEnrolmentResponse> startPhoneEnrolment(StartPhoneEnrolmentRequest startPhoneEnrolmentRequest) Starts the enrolment of a phone: a verification code is sent by SMS.org.springframework.http.ResponseEntity<PhoneResponse> verifyPhone(VerifyPhoneRequest verifyPhoneRequest) Confirms the phone with the code received by SMS.
-
Field Details
-
ACCOUNT_KEY_PREFIX
Prefix of the rate-limit key of an account, which cannot clash with a user name typed in a sign-in form.- See Also:
-
currentAccountResolver
Resolves the account of the request. -
findUserPhoneUseCase
Finds the verified phone of the account. -
startPhoneEnrolmentUseCase
Starts an enrolment. -
confirmPhoneUseCase
Confirms an enrolment. -
removePhoneUseCase
Removes the phone. -
stepUpGuard
Requires a recent multi-factor sign-in before the phone is replaced or removed. -
rateLimiter
Limits the requests. -
phoneDtoMapper
Maps the results onto the contract's DTOs. -
request
private final jakarta.servlet.http.HttpServletRequest requestThe current request, injected as a thread-bound proxy, which tells the address of the client.
-
-
Constructor Details
-
PhoneController
public PhoneController()
-
-
Method Details
-
getPhone
Gets the verified phone, masked.- Specified by:
getPhonein interfacePhoneApi- Returns:
200 OKwith the phone.- Throws:
PhoneNotFoundException- if the account has no verified phone.
-
startPhoneEnrolment
public org.springframework.http.ResponseEntity<PhoneEnrolmentResponse> startPhoneEnrolment(StartPhoneEnrolmentRequest startPhoneEnrolmentRequest) Starts the enrolment of a phone: a verification code is sent by SMS.- Specified by:
startPhoneEnrolmentin interfacePhoneApi- Parameters:
startPhoneEnrolmentRequest- the number.- Returns:
202 Acceptedwith how long the code stays valid.- Throws:
InsufficientUserAuthenticationException- if the account has a confirmed second factor and the token does not show a recent multi-factor sign-in.OttRateLimitExceededException- if the client or the account asked too many times.
-
verifyPhone
public org.springframework.http.ResponseEntity<PhoneResponse> verifyPhone(VerifyPhoneRequest verifyPhoneRequest) Confirms the phone with the code received by SMS.- Specified by:
verifyPhonein interfacePhoneApi- Parameters:
verifyPhoneRequest- the code.- Returns:
200 OKwith the verified phone.- Throws:
InvalidPhoneCodeException- if the code is not valid.OttRateLimitExceededException- if the client or the account tried too many times.
-
removePhone
Removes the phone and any pending verification.- Specified by:
removePhonein interfacePhoneApi- Returns:
204 No Content.- Throws:
InsufficientUserAuthenticationException- if the token does not show a recent multi-factor sign-in.
-