Class TotpController
java.lang.Object
com.irurueta.authserver.authorization.api.web.totp.TotpController
- All Implemented Interfaces:
TotpApi
Enrols, confirms and disables the authenticator app of the authenticated account. The paths, status codes and
bodies are those of the contract
apis/auth-server/rest-server/auth-server-api-v1.yaml, through the
generated TotpApi; failures are answered by
MfaExceptionHandler. Answers that carry a secret are
never cached. Disabling the app needs a recent multi-factor sign-in (StepUpGuard).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConfirmTotpUseCaseConfirms an enrolment.private final CurrentAccountResolverResolves the account of the request.private final DisableTotpUseCaseDisables the authenticator app.private final EnrollTotpUseCaseStarts an enrolment.private final QrCodeRendererRenders the enrolment URI as a QR code.private final StepUpGuardRequires a recent multi-factor sign-in before the second factor is removed.private final TotpDtoMapperMaps the results onto the contract's DTOs.Fields inherited from interface com.irurueta.authserver.authorization.api.web.v1.generated.api.TotpApi
PATH_CONFIRM_TOTP, PATH_DISABLE_TOTP, PATH_ENROLL_TOTP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<RecoveryCodesResponse> confirmTotp(ConfirmTotpRequest request) Confirms the enrolment with a code from the authenticator app.org.springframework.http.ResponseEntity<Void> Disables the authenticator app, removes the recovery codes and revokes the trusted devices.org.springframework.http.ResponseEntity<TotpEnrollmentResponse> Starts the enrolment of an authenticator app.private static <T> org.springframework.http.ResponseEntity<T> noStore(T body) Answers a body that carries a secret, which must not be cached.
-
Field Details
-
currentAccountResolver
Resolves the account of the request. -
enrollTotpUseCase
Starts an enrolment. -
confirmTotpUseCase
Confirms an enrolment. -
disableTotpUseCase
Disables the authenticator app. -
stepUpGuard
Requires a recent multi-factor sign-in before the second factor is removed. -
qrCodeRenderer
Renders the enrolment URI as a QR code. -
totpDtoMapper
Maps the results onto the contract's DTOs.
-
-
Constructor Details
-
TotpController
public TotpController()
-
-
Method Details
-
enrollTotp
Starts the enrolment of an authenticator app.- Specified by:
enrollTotpin interfaceTotpApi- Returns:
200 OKwith theotpauthURI and its QR code.
-
confirmTotp
public org.springframework.http.ResponseEntity<RecoveryCodesResponse> confirmTotp(ConfirmTotpRequest request) Confirms the enrolment with a code from the authenticator app.- Specified by:
confirmTotpin interfaceTotpApi- Parameters:
request- the code.- Returns:
200 OKwith the recovery codes, shown only once.
-
disableTotp
Disables the authenticator app, removes the recovery codes and revokes the trusted devices.- Specified by:
disableTotpin interfaceTotpApi- Returns:
204 No Content.- Throws:
InsufficientUserAuthenticationException- if the token does not show a recent multi-factor sign-in.
-
noStore
private static <T> org.springframework.http.ResponseEntity<T> noStore(T body) Answers a body that carries a secret, which must not be cached.- Type Parameters:
T- type of the body.- Parameters:
body- the body.- Returns:
200 OKwithCache-Control: no-store.
-