Class TotpSecondFactorFragment
java.lang.Object
com.irurueta.authserver.authorization.api.web.totp.TotpSecondFactorFragment
- All Implemented Interfaces:
SecondFactorFragment
Contributes the TOTP forms to the second-factor page, as every second factor does through the
SecondFactorFragment extension point. What the fragment shows depends on the signed-in user:
- without a confirmed authenticator app but with another confirmed second factor (for example a passkey), nothing: that factor completes the sign-in, so no secret is generated and no enrolment is offered;
- without any confirmed second factor, the enrolment form: a new secret is generated (replacing any pending
one), shown as a QR code and as its
otpauthURI, and the first code confirms it; - with one, the form of its code and the recovery-code form, plus a warning when 3 or fewer recovery codes are left.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringModel attribute with the number of unused recovery codes.static final StringModel attribute telling the fragment to warn that few recovery codes are left.private final CountRecoveryCodesUseCaseCounts the unused recovery codes.private final EnrollTotpUseCaseStarts an enrolment.static final StringModel attribute telling the fragment to show the enrolment form.private final HasConfirmedSecondFactorUseCaseTells whether the user has confirmed another second factor.private final IsTotpEnabledUseCaseTells whether the user has a confirmed authenticator app.static final StringModel attribute telling the fragment to show anything at all.static final intPosition of the TOTP forms in the second-factor page.static final StringModel attribute with theotpauthURI of the enrolment.static final StringModel attribute with the QR code of the enrolment, as adata:URI.private final QrCodeRendererRenders the enrolment URI as a QR code.private final SecondFactorUserResolverResolves the identifier of the account of the signed-in user. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the name of the fragment inside the template.modelAttributes(org.springframework.security.core.Authentication authentication) Supplies the enrolment (a new pending secret) to a user without any confirmed second factor, the number of recovery codes left to a user with a confirmed authenticator app, and hides the forms from a user whose only confirmed second factors are other ones.intorder()Gets the position of the fragment in the page; lower values are rendered first.Gets the name of the template that holds the fragment.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.irurueta.authserver.authorization.api.web.mfa.SecondFactorFragment
reference
-
Field Details
-
ORDER
public static final int ORDERPosition of the TOTP forms in the second-factor page.- See Also:
-
OFFERED_ATTRIBUTE
Model attribute telling the fragment to show anything at all.- See Also:
-
ENROLMENT_ATTRIBUTE
Model attribute telling the fragment to show the enrolment form.- See Also:
-
OTPAUTH_URI_ATTRIBUTE
Model attribute with theotpauthURI of the enrolment.- See Also:
-
QR_CODE_ATTRIBUTE
Model attribute with the QR code of the enrolment, as adata:URI.- See Also:
-
CODES_LEFT_ATTRIBUTE
Model attribute with the number of unused recovery codes.- See Also:
-
CODES_LOW_ATTRIBUTE
Model attribute telling the fragment to warn that few recovery codes are left.- See Also:
-
userResolver
Resolves the identifier of the account of the signed-in user. -
isTotpEnabledUseCase
Tells whether the user has a confirmed authenticator app. -
hasConfirmedSecondFactorUseCase
Tells whether the user has confirmed another second factor. -
enrollTotpUseCase
Starts an enrolment. -
countRecoveryCodesUseCase
Counts the unused recovery codes. -
qrCodeRenderer
Renders the enrolment URI as a QR code.
-
-
Constructor Details
-
TotpSecondFactorFragment
public TotpSecondFactorFragment()
-
-
Method Details
-
templateName
Description copied from interface:SecondFactorFragmentGets the name of the template that holds the fragment.- Specified by:
templateNamein interfaceSecondFactorFragment- Returns:
- the template name.
-
fragmentName
Description copied from interface:SecondFactorFragmentGets the name of the fragment inside the template.- Specified by:
fragmentNamein interfaceSecondFactorFragment- Returns:
- the fragment name.
-
order
public int order()Description copied from interface:SecondFactorFragmentGets the position of the fragment in the page; lower values are rendered first.- Specified by:
orderin interfaceSecondFactorFragment- Returns:
- the order.
-
modelAttributes
public Map<String,Object> modelAttributes(org.springframework.security.core.Authentication authentication) Supplies the enrolment (a new pending secret) to a user without any confirmed second factor, the number of recovery codes left to a user with a confirmed authenticator app, and hides the forms from a user whose only confirmed second factors are other ones.- Specified by:
modelAttributesin interfaceSecondFactorFragment- Parameters:
authentication- the authentication of the user the page is rendered for.- Returns:
- the model attributes; none when nobody is signed in.
-