Class PhonePageController
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.PhonePageController
- All Implemented Interfaces:
PhonePageApi
Serves the phone account page and the session-protected form posts it uses, as the contract
apis/auth-server/web-pages/auth-server-pages-v1.yaml describes them through the generated
PhonePageApi. A browser page has a session, not a bearer token, so it cannot call the REST API
(/api/account/phone, which ApiSecurityConfig keeps bearer-only); the forms call the same use cases
instead, with the same limits, and each answers by redirecting back to the page (post/redirect/get) with the outcome
in the status parameter. The number is shown masked, as the REST API answers it.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConfirmPhoneUseCaseConfirms an enrolment.(package private) static final StringStatus of a number of a country SMS messages are not sent to.private final CurrentAccountResolverResolves the account of the request.private final FindUserPhoneUseCaseFinds the verified phone of the account.(package private) static final StringStatus of a wrong code.(package private) static final StringStatus of a number that is not valid.private final PageRendererRenders the page.(package private) static final StringStatus of a code that was requested.(package private) static final StringName of the model attribute that holds the masked verified number, absent when there is none.static final StringPath of the page, taken from the contract.private final PhoneDtoMapperMaps the phone onto its masked form.(package private) static final StringStatus of a request over a limit.private final OttRateLimiterLimits the requests.(package private) static final StringStatus of a number that was removed.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.(package private) static final StringName of the model attribute that holds the outcome of the previous post.The statuses the page tells; any other value of the parameter is ignored.(package private) static final StringStatus of an enrolment or a removal that needs a recent multi-factor sign-in.private final PhoneSessionStepUpRequires a recent multi-factor sign-in before the phone is replaced or removed.(package private) static final StringStatus of a number that was verified.(package private) static final StringName of the template of the page.Fields inherited from interface com.irurueta.authserver.authorization.api.web.pages.v1.generated.api.PhonePageApi
PATH_PHONE_PAGE, PATH_REMOVE_PHONE_PAGE, PATH_START_PHONE_ENROLMENT_PAGE, PATH_VERIFY_PHONE_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String> Renders the page.private org.springframework.http.ResponseEntity<Void> Builds the redirect back to the page.org.springframework.http.ResponseEntity<Void> Removes the phone, when the session shows a recent enough multi-factor sign-in.org.springframework.http.ResponseEntity<Void> startPhoneEnrolmentPage(String phone) Sends the verification code to the number, when the session shows a recent enough multi-factor sign-in for an account that already has a confirmed second factor (the new number would replace the verified one).org.springframework.http.ResponseEntity<Void> verifyPhonePage(String code) Confirms the number with the code.
-
Field Details
-
PHONE_PATH
Path of the page, taken from the contract.- See Also:
-
VIEW_NAME
Name of the template of the page.- See Also:
-
PHONE_ATTRIBUTE
Name of the model attribute that holds the masked verified number, absent when there is none.- See Also:
-
STATUS_ATTRIBUTE
Name of the model attribute that holds the outcome of the previous post.- See Also:
-
PENDING
Status of a code that was requested.- See Also:
-
VERIFIED
Status of a number that was verified.- See Also:
-
REMOVED
Status of a number that was removed.- See Also:
-
INVALID_PHONE
Status of a number that is not valid.- See Also:
-
COUNTRY_NOT_ALLOWED
Status of a number of a country SMS messages are not sent to.- See Also:
-
INVALID_CODE
Status of a wrong code.- See Also:
-
RATE_LIMITED
Status of a request over a limit.- See Also:
-
STEP_UP_REQUIRED
Status of an enrolment or a removal that needs a recent multi-factor sign-in.- See Also:
-
STATUSES
The statuses the page tells; any other value of the parameter is ignored. -
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. -
stepUp
Requires a recent multi-factor sign-in before the phone is replaced or removed. -
rateLimiter
Limits the requests. -
phoneDtoMapper
Maps the phone onto its masked form. -
pageRenderer
Renders the page. -
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
-
PhonePageController
public PhonePageController()
-
-
Method Details
-
phonePage
Renders the page.- Specified by:
phonePagein interfacePhonePageApi- Parameters:
status- outcome of the previous post, ignored when it is not one of the known ones.- Returns:
- the page, never cached.
-
startPhoneEnrolmentPage
Sends the verification code to the number, when the session shows a recent enough multi-factor sign-in for an account that already has a confirmed second factor (the new number would replace the verified one).- Specified by:
startPhoneEnrolmentPagein interfacePhonePageApi- Parameters:
phone- the number.- Returns:
- a redirect to the page; the status is
pendingwhether or not the number belongs to another account.
-
verifyPhonePage
Confirms the number with the code.- Specified by:
verifyPhonePagein interfacePhonePageApi- Parameters:
code- the code received by SMS.- Returns:
- a redirect to the page, with the outcome.
-
removePhonePage
Removes the phone, when the session shows a recent enough multi-factor sign-in.- Specified by:
removePhonePagein interfacePhonePageApi- Returns:
- a redirect to the page, with the outcome.
-
redirect
Builds the redirect back to the page.- Parameters:
status- the outcome.- Returns:
303 See Otherto the page.
-