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

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Claim carrying the authentication context class reference.
    private static final String
    Separator of the configured acr-values: any run of whitespace.
    (package private) static final String
    Claim carrying the time of the user's authentication, in epoch seconds.
    private final Clock
    Source of the current time.
    private final StepUpProperties
    Step-up policy.
    private final String
    Authority the caller needs before the step-up requirement is evaluated.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.authorization.AuthorizationResult
    authorize(Supplier<? extends org.springframework.security.core.Authentication> authentication, org.springframework.security.web.access.intercept.RequestAuthorizationContext context)
     
    private boolean
    Tells whether an acr value is one of the configured ones.
    private boolean
    satisfied(org.springframework.security.core.Authentication authentication)
    Tells whether the token proves the required authentication.
    private static Instant
    Converts an auth_time value, 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, wait

    Methods inherited from interface org.springframework.security.authorization.AuthorizationManager

    verify
  • Field Details

    • ACR_CLAIM

      static final String ACR_CLAIM
      Claim carrying the authentication context class reference.
      See Also:
    • AUTH_TIME_CLAIM

      static final String AUTH_TIME_CLAIM
      Claim carrying the time of the user's authentication, in epoch seconds.
      See Also:
    • ACR_VALUES_SEPARATOR

      private static final String ACR_VALUES_SEPARATOR
      Separator of the configured acr-values: any run of whitespace.
      See Also:
    • requiredAuthority

      private final String requiredAuthority
      Authority the caller needs before the step-up requirement is evaluated.
    • properties

      private final StepUpProperties properties
      Step-up policy.
    • clock

      private final Clock 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:
      authorize in interface org.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:
      true when the acr matches and auth_time is recent enough.
    • isAccepted

      private boolean isAccepted(Object acr)
      Tells whether an acr value is one of the configured ones. The configured acr-values is a space-separated list, like the acr_values parameter of OpenID Connect, so the token's single value must be a member of it, never equal to the whole list.
      Parameters:
      acr - the acr claim of the token.
      Returns:
      true when the claim is a text listed in the configured values.
    • toInstant

      private static Instant toInstant(Object value)
      Converts an auth_time value, which is epoch seconds in a JWT or an introspection answer.
      Parameters:
      value - the claim value.
      Returns:
      the instant, or null when the value is missing or of an unexpected type.