cleanups
This commit is contained in:
parent
7fb8f5ed28
commit
a286a92ede
5 changed files with 4 additions and 23 deletions
|
@ -37,7 +37,8 @@ public class InitialSecuritySetup {
|
|||
initialPassword = "stirling";
|
||||
userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId(), true);
|
||||
}
|
||||
|
||||
}
|
||||
if(!userService.usernameExists(Role.INTERNAL_API_USER.getRoleId())) {
|
||||
userService.saveUser(Role.INTERNAL_API_USER.getRoleId(), UUID.randomUUID().toString(), Role.INTERNAL_API_USER.getRoleId());
|
||||
userService.addApiKeyToUser(Role.INTERNAL_API_USER.getRoleId());
|
||||
}
|
||||
|
|
|
@ -9,17 +9,15 @@ import stirling.software.SPDF.model.AttemptCounter;
|
|||
@Service
|
||||
public class LoginAttemptService {
|
||||
|
||||
private final int MAX_ATTEMPTS = 2;
|
||||
private final int MAX_ATTEMPTS = 10;
|
||||
private final long ATTEMPT_INCREMENT_TIME = TimeUnit.MINUTES.toMillis(1);
|
||||
private final ConcurrentHashMap<String, AttemptCounter> attemptsCache = new ConcurrentHashMap<>();
|
||||
|
||||
public void loginSucceeded(String key) {
|
||||
System.out.println("here3 reset ");
|
||||
attemptsCache.remove(key);
|
||||
}
|
||||
|
||||
public boolean loginAttemptCheck(String key) {
|
||||
System.out.println("here");
|
||||
attemptsCache.compute(key, (k, attemptCounter) -> {
|
||||
if (attemptCounter == null || attemptCounter.shouldReset(ATTEMPT_INCREMENT_TIME)) {
|
||||
return new AttemptCounter();
|
||||
|
@ -28,7 +26,6 @@ public class LoginAttemptService {
|
|||
return attemptCounter;
|
||||
}
|
||||
});
|
||||
System.out.println("here2 = " + attemptsCache.get(key).getAttemptCount());
|
||||
return attemptsCache.get(key).getAttemptCount() >= MAX_ATTEMPTS;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class SecurityConfiguration {
|
|||
|
||||
@Bean
|
||||
public IPRateLimitingFilter rateLimitingFilter() {
|
||||
int maxRequestsPerIp = 10000; // Example limit
|
||||
int maxRequestsPerIp = 1000000; // Example limit TODO add config level
|
||||
return new IPRateLimitingFilter(maxRequestsPerIp, maxRequestsPerIp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package stirling.software.SPDF.controller.api.pipeline;
|
||||
public interface UserServiceInterface {
|
||||
// Define methods that you need
|
||||
String getApiKeyForUser(String username);
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package stirling.software.SPDF.controller.api.pipeline;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "DOCKER_ENABLE_SECURITY", havingValue = "false")
|
||||
public class UserServiceNoOpImpl implements UserServiceInterface {
|
||||
// Implement the methods with no-op
|
||||
@Override
|
||||
public String getApiKeyForUser(String username) {
|
||||
// No-op implementation
|
||||
return "";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue