Class DeviceVerificationRateLimiter

java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.DeviceVerificationRateLimiter

public final class DeviceVerificationRateLimiter extends Object
Rate limiter of the attempts to verify a user code, on the pattern of the other limiters of this server: Bucket4j token buckets in Caffeine caches (FixedWindowBuckets), one per client address and one per signed-in user, so a user code, which is short, cannot be guessed faster than the limits allow. The buckets live in this instance only: several instances each apply the limits on their own. The client address is request.getRemoteAddr(), so behind a proxy server.forward-headers-strategy must be set for it to be the real client.
  • Field Details

  • Constructor Details

    • DeviceVerificationRateLimiter

      public DeviceVerificationRateLimiter(DeviceRateLimitProperties properties, Clock clock)
      Creates the limiter.
      Parameters:
      properties - limits, window and bound of the tracked keys.
      clock - source of the current time.
  • Method Details

    • check

      public void check(String clientAddress, String userName)
      Counts one attempt and rejects it once a limit is exceeded.
      Parameters:
      clientAddress - address of the calling client, may be null.
      userName - name of the signed-in user.
      Throws:
      DeviceVerificationRateLimitedException - if the client address or the user exceeded its limit.