Class StepUpAuthorizationRequestConverter
java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.StepUpAuthorizationRequestConverter
- All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationConverter
public class StepUpAuthorizationRequestConverter
extends Object
implements org.springframework.security.web.authentication.AuthenticationConverter
Applies the OpenID Connect step-up parameters of an authorization request to the authentication of the session. It
is installed first among the converters of
/oauth2/authorize and never converts anything: it either lets
the request go on (returning null) or refuses it. The factors and their instants are read through the
FactorTimeline, so a remembered (trusted) device never counts here.
max_age: when the primary factor was presented more than that many whole seconds ago, aReauthenticationRequiredExceptionmakes the user sign in again. A session whose factors are unknown (no counted factor of the registry) is left alone, because it could never satisfy the request and the user would loop through the login page.acr_values: when the request asks only for classes ofAuthenticationContextClassthat the session has not reached, a step-upSecondFactorRequiredExceptionsends the user to the second-factor page, which then asks for a real second factor even on a trusted device. The multi-factor class also satisfies a request for the password class. Classes this server does not know are ignored, as the specification makesacr_valuesvoluntary.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the request parameter with the space-separated authentication context classes asked for.private final ClockClock the age of the authentication is measured with.private final FactorTimelineReads the counted factors of the session and their instants.static final StringName of the request parameter with the maximum age, in seconds, of the authentication. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanacrReached(String acrValues, boolean multiFactor) Tells whether the session reached any of the requested classes.org.springframework.security.core.Authenticationconvert(jakarta.servlet.http.HttpServletRequest request) Checks the step-up parameters of a request.private booleanmaxAgeExceeded(String maxAge, Instant authTime) Tells whether the authentication is older than the request tolerates.
-
Field Details
-
MAX_AGE_PARAMETER
Name of the request parameter with the maximum age, in seconds, of the authentication.- See Also:
-
ACR_VALUES_PARAMETER
Name of the request parameter with the space-separated authentication context classes asked for.- See Also:
-
factorTimeline
Reads the counted factors of the session and their instants. -
clock
Clock the age of the authentication is measured with.
-
-
Constructor Details
-
StepUpAuthorizationRequestConverter
public StepUpAuthorizationRequestConverter()
-
-
Method Details
-
convert
public org.springframework.security.core.Authentication convert(jakarta.servlet.http.HttpServletRequest request) Checks the step-up parameters of a request.- Specified by:
convertin interfaceorg.springframework.security.web.authentication.AuthenticationConverter- Parameters:
request- the request.- Returns:
- always
null: this converter only vetoes requests. - Throws:
ReauthenticationRequiredException- ifmax_ageis exceeded.SecondFactorRequiredException- if the requestedacr_valuesare not reached.
-
maxAgeExceeded
Tells whether the authentication is older than the request tolerates.- Parameters:
maxAge- themax_ageparameter, may benull; a value that is not a non-negative integer is ignored.authTime- the instant the primary factor was presented.- Returns:
truewhen more thanmaxAgewhole seconds have elapsed.
-
acrReached
Tells whether the session reached any of the requested classes.- Parameters:
acrValues- the space-separatedacr_valuesparameter, may benull.multiFactor- whether the session presented at least two distinct factors.- Returns:
truewhen no known class is requested or one of them is reached.
-