ilgrosso commented on code in PR #1413:
URL: https://github.com/apache/syncope/pull/1413#discussion_r3378548007
##########
core/self-keymaster-starter/src/main/java/org/apache/syncope/core/keymaster/rest/security/SelfKeymasterUsernamePasswordAuthenticationProvider.java:
##########
@@ -38,17 +40,25 @@ public SelfKeymasterUsernamePasswordAuthenticationProvider(
final UserProvisioningManager provisioningManager,
final SecurityProperties securityProperties,
final EncryptorManager encryptorManager,
+ final Cache<String, AuthenticationAttemptThrottler.Attempts>
authenticationAttemptCache,
final KeymasterProperties keymasterProperties) {
- super(domainOps, dataAccessor, provisioningManager,
securityProperties, encryptorManager);
+ super(
Review Comment:
why this formatting change? please revert
##########
core/self-keymaster-starter/src/main/java/org/apache/syncope/core/keymaster/rest/security/SelfKeymasterUsernamePasswordAuthenticationProvider.java:
##########
@@ -38,17 +40,25 @@ public SelfKeymasterUsernamePasswordAuthenticationProvider(
final UserProvisioningManager provisioningManager,
final SecurityProperties securityProperties,
final EncryptorManager encryptorManager,
+ final Cache<String, AuthenticationAttemptThrottler.Attempts>
authenticationAttemptCache,
final KeymasterProperties keymasterProperties) {
- super(domainOps, dataAccessor, provisioningManager,
securityProperties, encryptorManager);
+ super(
+ domainOps,
+ dataAccessor,
+ provisioningManager,
+ securityProperties,
+ encryptorManager,
+ authenticationAttemptCache);
this.keymasterProperties = keymasterProperties;
}
@Override
public Authentication authenticate(final Authentication authentication) {
if
(keymasterProperties.getUsername().equals(authentication.getName())) {
return finalizeAuthentication(
-
SyncopeAuthenticationDetails.class.cast(authentication.getDetails()).getDomain(),
+ ((SyncopeAuthenticationDetails)
authentication.getDetails()).getDomain(),
Review Comment:
please revert
##########
core/spring/src/main/java/org/apache/syncope/core/spring/security/AuthenticationAttemptThrottler.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.spring.security;
+
+import java.io.Serializable;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.concurrent.TimeUnit;
+import java.util.function.LongSupplier;
+import javax.cache.Cache;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.expiry.TouchedExpiryPolicy;
+import org.apache.commons.lang3.StringUtils;
+
+public class AuthenticationAttemptThrottler {
+
+ public static final String CACHE_NAME =
+
"org.apache.syncope.core.spring.security.AuthenticationAttemptThrottler";
+
+ public record Attempts(Deque<Long> failures, long blockedUntil) implements
Serializable {
+
+ private static final long serialVersionUID = 8023582605543650484L;
+
+ public Attempts {
+ failures = new ArrayDeque<>(failures);
+ }
+
+ private Attempts() {
+ this(new ArrayDeque<>(), 0);
+ }
+ }
+
+ private final SecurityProperties.AuthenticationThrottleProperties throttle;
Review Comment:
Make all `private` stuff as `protected` to allow for extensions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]