Class StepUpGuard
java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.StepUpGuard
Guards the API operations that remove or reset a second factor (disabling the authenticator app, generating new
recovery codes, revoking a trusted device): a stolen token, or a session left open, must not be enough to weaken the
account. While the account has a confirmed second factor, the bearer token must show a multi-factor sign-in
(
acr "urn:irurueta:acr:mfa") whose auth_time is within
authserver.mfa.step-up-max-age; otherwise an InsufficientUserAuthenticationException asks the client
to step up (RFC 9470). An account without a second factor cannot step up, so it is not asked to. The controllers call
it first; the /api/** chain itself is not changed.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClockClock the age of the sign-in is measured with.private final HasConfirmedSecondFactorUseCaseTells whether the account has a confirmed second factor.private final MfaPropertiesMulti-factor settings, with the maximum age of the sign-in. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanisRecentMultiFactor(org.springframework.security.oauth2.jwt.Jwt jwt, Duration maxAge) Tells whether a token shows a multi-factor sign-in that is recent enough.voidrequireRecentMultiFactor(UUID userId) Requires a recent multi-factor sign-in from the bearer token of the current request.
-
Field Details
-
hasConfirmedSecondFactorUseCase
Tells whether the account has a confirmed second factor. -
mfaProperties
Multi-factor settings, with the maximum age of the sign-in. -
clock
Clock the age of the sign-in is measured with.
-
-
Constructor Details
-
StepUpGuard
public StepUpGuard()
-
-
Method Details
-
requireRecentMultiFactor
Requires a recent multi-factor sign-in from the bearer token of the current request.- Parameters:
userId- identifier of the account the operation acts on.- Throws:
InsufficientUserAuthenticationException- if the account has a confirmed second factor and the token does not show a recent enough multi-factor sign-in.
-
isRecentMultiFactor
private boolean isRecentMultiFactor(org.springframework.security.oauth2.jwt.Jwt jwt, Duration maxAge) Tells whether a token shows a multi-factor sign-in that is recent enough.- Parameters:
jwt- the bearer token.maxAge- maximum age of the sign-in.- Returns:
truewhenacris the multi-factor class andauth_timeis at mostmaxAgeold (and not in the future).
-