mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
improved logging for locking/banning of user accounts and client IPs
This commit is contained in:
1 parent
df2b2b33e6
commit
2cd0bb2fec
2 files changed
+9
-2
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package com.sap.sse.security;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
@@ -7,12 +9,14 @@ import org.apache.shiro.authc.LockedAccountException;
|
||||
import org.apache.shiro.authc.SaltedAuthenticationInfo;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
|
||||
import com.sap.sse.security.shared.Account.AccountType;
|
||||
import com.sap.sse.security.shared.impl.User;
|
||||
import com.sap.sse.security.interfaces.SimpleSaltedAuthenticationInfo;
|
||||
import com.sap.sse.security.shared.Account.AccountType;
|
||||
import com.sap.sse.security.shared.UsernamePasswordAccount;
|
||||
import com.sap.sse.security.shared.impl.User;
|
||||
|
||||
public class UsernamePasswordRealm extends AbstractCompositeAuthorizingRealm {
|
||||
private static final Logger logger = Logger.getLogger(UsernamePasswordRealm.class.getName());
|
||||
|
||||
public UsernamePasswordRealm() {
|
||||
super();
|
||||
setAuthenticationTokenClass(UsernamePasswordToken.class);
|
||||
@@ -46,6 +50,7 @@ public class UsernamePasswordRealm extends AbstractCompositeAuthorizingRealm {
|
||||
return null;
|
||||
}
|
||||
if (user.getLockingAndBanning().isAuthenticationLocked()) {
|
||||
logger.warning("Rejected attempt to authenticate user "+username+" because it is locked: "+user.getLockingAndBanning());
|
||||
throw new LockedAccountException("Password authentication for user "+username+" is currently locked");
|
||||
}
|
||||
final UsernamePasswordAccount upa = (UsernamePasswordAccount) user.getAccount(AccountType.USERNAME_PASSWORD);
|
||||
|
||||
@@ -1291,6 +1291,7 @@ implements ReplicableSecurityService, ClearStateTestSupport {
|
||||
lockingAndBanning = user.getLockingAndBanning();
|
||||
lockingAndBanning.failedPasswordAuthentication();
|
||||
store.updateUser(user);
|
||||
logger.info("failed password authentication for user "+username+"; locking: "+lockingAndBanning);
|
||||
} else {
|
||||
lockingAndBanning = null;
|
||||
}
|
||||
@@ -1329,6 +1330,7 @@ implements ReplicableSecurityService, ClearStateTestSupport {
|
||||
public LockingAndBanning internalFailedBearerTokenAuthentication(String clientIP) {
|
||||
final LockingAndBanning lockingAndBanning = clientIPBasedLockingAndBanningForBearerTokenAuthentication.computeIfAbsent(escapeNullClientIP(clientIP), key->new LockingAndBanningImpl());
|
||||
lockingAndBanning.failedPasswordAuthentication();
|
||||
logger.info("failed bearer token authentication from client IP "+clientIP+"; locking: "+lockingAndBanning);
|
||||
scheduleCleanUpTask(clientIP, lockingAndBanning, clientIPBasedLockingAndBanningForBearerTokenAuthentication,
|
||||
"client IPs locked for bearer token authentication");
|
||||
return lockingAndBanning;
|
||||
|
||||
Reference in new issue
Block a user