Class DeviceVerificationRateLimiter
java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.DeviceVerificationRateLimiter
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final FixedWindowBucketsBuckets per client address.private final DeviceRateLimitPropertiesLimits, window and bound of the tracked keys.private static final StringKey used when the client address is unknown.private final FixedWindowBucketsBuckets per signed-in user. -
Constructor Summary
ConstructorsConstructorDescriptionDeviceVerificationRateLimiter(DeviceRateLimitProperties properties, Clock clock) Creates the limiter. -
Method Summary
-
Field Details
-
UNKNOWN_CLIENT
Key used when the client address is unknown.- See Also:
-
properties
Limits, window and bound of the tracked keys. -
clients
Buckets per client address. -
users
Buckets per signed-in user.
-
-
Constructor Details
-
DeviceVerificationRateLimiter
Creates the limiter.- Parameters:
properties- limits, window and bound of the tracked keys.clock- source of the current time.
-
-
Method Details
-
check
Counts one attempt and rejects it once a limit is exceeded.- Parameters:
clientAddress- address of the calling client, may benull.userName- name of the signed-in user.- Throws:
DeviceVerificationRateLimitedException- if the client address or the user exceeded its limit.
-