Record Class MfaProperties

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.application.mfa.MfaProperties
Record Components:
maxFailedAttempts - consecutive failed second-factor attempts that lock the second factor (default 5).
lockout - how long the second factor stays locked (default 15 minutes).
trustedDeviceValidity - how long a device stays trusted (default 30 days).
totpIssuer - issuer shown by the authenticator app (default Irurueta Auth Server).
stepUpMaxAge - how recent the multi-factor sign-in of a bearer token must be to remove or reset a second factor through the API (default 5 minutes).

@ConfigurationProperties("authserver.mfa") public record MfaProperties(int maxFailedAttempts, Duration lockout, Duration trustedDeviceValidity, String totpIssuer, Duration stepUpMaxAge) extends Record
Multi-factor settings, bound once from authserver.mfa.* and injected wherever one of them is needed (the use cases of this module and the step-up guard of the API). A value left out takes its default; an invalid one stops the application at startup.
  • Field Details

    • maxFailedAttempts

      private final int maxFailedAttempts
      The field for the maxFailedAttempts record component.
    • lockout

      private final Duration lockout
      The field for the lockout record component.
    • trustedDeviceValidity

      private final Duration trustedDeviceValidity
      The field for the trustedDeviceValidity record component.
    • totpIssuer

      private final String totpIssuer
      The field for the totpIssuer record component.
    • stepUpMaxAge

      private final Duration stepUpMaxAge
      The field for the stepUpMaxAge record component.
  • Constructor Details

    • MfaProperties

      public MfaProperties(@DefaultValue("5") int maxFailedAttempts, @DefaultValue("PT15M") Duration lockout, @DefaultValue("P30D") Duration trustedDeviceValidity, @DefaultValue("Irurueta Auth Server") String totpIssuer, @DefaultValue("PT5M") Duration stepUpMaxAge)
      Validates the settings.
      Throws:
      IllegalArgumentException - if maxFailedAttempts is less than one, a duration is missing or not positive, or the issuer is blank.
  • Method Details

    • requirePositive

      private static void requirePositive(Duration value, String key)
      Rejects a missing or non-positive duration.
      Parameters:
      value - the duration.
      key - the key of the setting, below authserver.mfa.
      Throws:
      IllegalArgumentException - if the duration is missing, zero or negative.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxFailedAttempts

      public int maxFailedAttempts()
      Returns the value of the maxFailedAttempts record component.
      Returns:
      the value of the maxFailedAttempts record component
    • lockout

      public Duration lockout()
      Returns the value of the lockout record component.
      Returns:
      the value of the lockout record component
    • trustedDeviceValidity

      public Duration trustedDeviceValidity()
      Returns the value of the trustedDeviceValidity record component.
      Returns:
      the value of the trustedDeviceValidity record component
    • totpIssuer

      public String totpIssuer()
      Returns the value of the totpIssuer record component.
      Returns:
      the value of the totpIssuer record component
    • stepUpMaxAge

      public Duration stepUpMaxAge()
      Returns the value of the stepUpMaxAge record component.
      Returns:
      the value of the stepUpMaxAge record component