Class StepUpAuthorizationManager
java.lang.Object
com.irurueta.authserver.resourceserver.api.web.security.StepUpAuthorizationManager
- All Implemented Interfaces:
org.springframework.security.authorization.AuthorizationManager<org.springframework.security.web.access.intercept.RequestAuthorizationContext>
public class StepUpAuthorizationManager
extends Object
implements org.springframework.security.authorization.AuthorizationManager<org.springframework.security.web.access.intercept.RequestAuthorizationContext>
Requires that the bearer token proves a recent strong authentication (RFC 9470): its
acr claim must be
one of the configured (space-separated) values and its auth_time claim no older than the configured maximum
age. The claims are read from the token attributes, so it serves JWTs (their claims) and opaque tokens (the
introspection answer) alike.
A caller without the requiredAuthority is denied with an ordinary decision (answered
403 insufficient_scope); a caller that has it but fails the step-up check is denied with a
StepUpRequiredDecision, which StepUpAccessDeniedHandler answers with the RFC 9470 challenge.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringClaim carrying the authentication context class reference.private static final StringSeparator of the configuredacr-values: any run of whitespace.(package private) static final StringClaim carrying the time of the user's authentication, in epoch seconds.private final ClockSource of the current time.private final StepUpPropertiesStep-up policy.private final StringAuthority the caller needs before the step-up requirement is evaluated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authorization.AuthorizationResultauthorize(Supplier<? extends org.springframework.security.core.Authentication> authentication, org.springframework.security.web.access.intercept.RequestAuthorizationContext context) private booleanisAccepted(Object acr) Tells whether anacrvalue is one of the configured ones.private booleansatisfied(org.springframework.security.core.Authentication authentication) Tells whether the token proves the required authentication.private static InstantConverts anauth_timevalue, which is epoch seconds in a JWT or an introspection answer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.authorization.AuthorizationManager
verify
-
Field Details
-
ACR_CLAIM
Claim carrying the authentication context class reference.- See Also:
-
AUTH_TIME_CLAIM
Claim carrying the time of the user's authentication, in epoch seconds.- See Also:
-
ACR_VALUES_SEPARATOR
Separator of the configuredacr-values: any run of whitespace.- See Also:
-
requiredAuthority
Authority the caller needs before the step-up requirement is evaluated. -
properties
Step-up policy. -
clock
Source of the current time.
-
-
Constructor Details
-
StepUpAuthorizationManager
public StepUpAuthorizationManager()
-
-
Method Details
-
authorize
public org.springframework.security.authorization.AuthorizationResult authorize(Supplier<? extends org.springframework.security.core.Authentication> authentication, org.springframework.security.web.access.intercept.RequestAuthorizationContext context) - Specified by:
authorizein interfaceorg.springframework.security.authorization.AuthorizationManager<org.springframework.security.web.access.intercept.RequestAuthorizationContext>
-
satisfied
private boolean satisfied(org.springframework.security.core.Authentication authentication) Tells whether the token proves the required authentication.- Parameters:
authentication- the authenticated bearer token.- Returns:
truewhen theacrmatches andauth_timeis recent enough.
-
isAccepted
Tells whether anacrvalue is one of the configured ones. The configuredacr-valuesis a space-separated list, like theacr_valuesparameter of OpenID Connect, so the token's single value must be a member of it, never equal to the whole list.- Parameters:
acr- theacrclaim of the token.- Returns:
truewhen the claim is a text listed in the configured values.
-
toInstant
Converts anauth_timevalue, which is epoch seconds in a JWT or an introspection answer.- Parameters:
value- the claim value.- Returns:
- the instant, or
nullwhen the value is missing or of an unexpected type.
-