Package org.wildfly.security.auth.realm
Class BruteForceRealmWrapper
java.lang.Object
org.wildfly.security.auth.realm.BruteForceRealmWrapper
A wrapper around
SecurityRealm instances to add brute force detection
for brute force password guessing attacks.
After a failed authentication attempt a FailureSession is created to track
the failure count and to coordinate temporarily disabling the identity.
This implementation is entirely in memory so will be cleared if the server is
reloaded or restarted.- Author:
- Darran Lofthouse
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAdditionalInterface(Class<?> interfaze) Add an additional interface to be proxied by the dynamic proxy.static BruteForceRealmWrappercreate()Create a new instance ofBruteForceRealmWrapperthat can be used to wrap aSecurityRealminstance and provide brute force protection.setFailureSessionTimeout(int failureSessionTimeout) After a failed authentication attempt how long in minutes to keep the tracking session alive.setLockoutInterval(int lockoutInterval) After the maximum number of failed authentication attempts the interval in minutes the account will be locked for.setMaxCachedSessions(int maxCachedSessions) Set the maximum number of sessions that will be cached before the least recently used session is evicted from the cache.setMaxFailedAttempts(int maxFailedAttempts) Set the maximum number of consecutive failed login attempts for a specific user before the lockout kicks in for the configured interval.setRealmName(String realmName) Set the realm name that should be used in any log messages.withExecutor(ScheduledExecutorService executor) Set theScheduledExecutorServicethat will be used for expiring the sessions tracking authentication failures.<S extends SecurityRealm>
Swrapping(SecurityRealm toWrap) Set the security realm that is to be wrapped by the wrapper.
-
Constructor Details
-
BruteForceRealmWrapper
public BruteForceRealmWrapper()
-
-
Method Details
-
create
Create a new instance ofBruteForceRealmWrapperthat can be used to wrap aSecurityRealminstance and provide brute force protection.- Returns:
- a new instance of
BruteForceRealmWrapper.
-
withExecutor
Set theScheduledExecutorServicethat will be used for expiring the sessions tracking authentication failures.- Parameters:
executor- theScheduledExecutorService- Returns:
thisto allow chaining.
-
setRealmName
Set the realm name that should be used in any log messages. If no realm name is specified the simple class name of the wrapped realm will be used instead.- Parameters:
realmName- the realm name that should be used in any log messages.- Returns:
thisto allow chaining.
-
setMaxFailedAttempts
Set the maximum number of consecutive failed login attempts for a specific user before the lockout kicks in for the configured interval.- Parameters:
maxFailedAttempts- - the maximum number of failed attempts before the lockout interval kicks in.- Returns:
thisto allow chaining.
-
setLockoutInterval
After the maximum number of failed authentication attempts the interval in minutes the account will be locked for. Subsequent failed attempts during the lockout period will renew the lockout indefinitely, even if those attempts use the correct credential.- Parameters:
lockoutInterval- the lockout interval in minutes.- Returns:
thisto allow chaining.
-
setFailureSessionTimeout
After a failed authentication attempt how long in minutes to keep the tracking session alive. Subsequent failed attempts will renew the timeout.- Parameters:
failureSessionTimeout- the lockout interval in minutes.- Returns:
thisto allow chaining.
-
setMaxCachedSessions
Set the maximum number of sessions that will be cached before the least recently used session is evicted from the cache.- Parameters:
maxCachedSessions- the maximum number of sessions that will be cached before the least recently used session is evicted.- Returns:
thisto allow chaining.
-
addAdditionalInterface
Add an additional interface to be proxied by the dynamic proxy.- Parameters:
interfaze- an additional interface to be proxied by the dynamic proxy.- Returns:
thisto allow chaining.
-
wrapping
Set the security realm that is to be wrapped by the wrapper.- Parameters:
toWrap- the security realm that is to be wrapped by the wrapper.- Returns:
thisto allow chaining.
-
wrap
-