[java-idp-plugin-duo] branch main updated: JDUO-85 - Admin API needs to implement rate limiting

Phil Smart philip.smart at jisc.ac.uk
Tue Apr 2 11:56:53 UTC 2024


This is an automated email from the git hooks/post-receive script.

philsmart pushed a commit to branch main
in repository java-idp-plugin-duo.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=4de23a90afaf1ebc93a0e8b66dea7e6abec854de

The following commit(s) were added to refs/heads/main by this push:
     new 4de23a90 JDUO-85 - Admin API needs to implement rate limiting
4de23a90 is described below

commit 4de23a90afaf1ebc93a0e8b66dea7e6abec854de
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Tue Apr 2 12:56:51 2024 +0100

    JDUO-85 - Admin API needs to implement rate limiting
    
     - Fix and re-enable test
    
    https://shibboleth.atlassian.net/browse/JDUO-85
---
 .../idp/plugin/authn/duo/impl/DefaultDuoAdminClient.java       |  2 +-
 .../authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java     | 10 +++++++++-
 .../shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java |  7 ++++---
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DefaultDuoAdminClient.java b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DefaultDuoAdminClient.java
index 90a72deb..74a97a18 100644
--- a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DefaultDuoAdminClient.java
+++ b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DefaultDuoAdminClient.java
@@ -395,7 +395,7 @@ public class DefaultDuoAdminClient extends AbstractIdentifiableInitializableComp
                     final int newBackoff = backoff * backoffFactor;
                     return doAPIRequest(request, wrapperTypeRef, newBackoff);
                 } else {
-                    log.warn("Duo admin API request rejected due to rate limiting, exhausted backoff attemots");
+                    log.warn("Duo admin API request rejected due to rate limiting, exhausted backoff attempts");
                 }
             }
             
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
index 305d39f2..dfcb4743 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
@@ -38,6 +38,7 @@ import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.ssl.SSLContexts;
 import org.mockito.Mockito;
 import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.storage.impl.MemoryStorageService;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -73,6 +74,7 @@ import com.google.common.net.HttpHeaders;
 import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
 import net.shibboleth.idp.authn.context.AuthenticationContext;
 import net.shibboleth.idp.authn.context.SubjectCanonicalizationContext;
+import net.shibboleth.idp.authn.impl.StorageBackedAccountLockoutManager;
 import net.shibboleth.idp.plugin.authn.duo.DuoOIDCClientFactory;
 import net.shibboleth.idp.plugin.authn.spring.CustomAbstractXmlFlowExecutionTests;
 import net.shibboleth.idp.plugin.authn.spring.CustomFlowModelFlowBuilder;
@@ -161,7 +163,7 @@ public abstract class AbstractAuthnXmlFlowExecutionTests extends CustomAbstractX
     @Nonnull private List<Flow> subflows;
     
     /** Map of properties to set.*/
-    @Nonnull private Map<String,String> mockProperties;
+    @Nonnull protected Map<String,String> mockProperties;
     
     /** The Duo client factory to use.*/
     @Nullable private DuoOIDCClientFactory clientFactory;  
@@ -456,6 +458,12 @@ public abstract class AbstractAuthnXmlFlowExecutionTests extends CustomAbstractX
         // Add bean to allow runtime exceptions to be logged (rather than a stack overflow).
         addBeanDefinition(builderContext, "LogRuntimeException",BeanDefinitionBuilder.
                 genericBeanDefinition(net.shibboleth.idp.profile.LogRuntimeException.class).getBeanDefinition());
+        
+        addBeanDefinition(builderContext, "shibboleth.StorageService",BeanDefinitionBuilder.
+                genericBeanDefinition(MemoryStorageService.class).setInitMethodName("initialize").getBeanDefinition());
+        
+        addBeanDefinition(builderContext, "shibboleth.StorageBackedAccountLockoutManager",BeanDefinitionBuilder.
+                genericBeanDefinition(StorageBackedAccountLockoutManager.class).setAbstract(true).getBeanDefinition());
 
         if (clientFactory != null) {
             //register the client factory
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java
index 338ecad3..8475d7a6 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java
@@ -142,9 +142,10 @@ public class DuoAuthnFlowTest extends AbstractAuthnXmlFlowExecutionTests {
     protected void registerMockBeanDefinitions(@Nonnull final MockFlowBuilderContext builderContext) {
         super.registerMockBeanDefinitions(builderContext);
         
+        // Inject the mock properties into the postconfig file as well as those loader directly by the builder
         loadBeanDefinitionsFromXmlFile(builderContext, 
                 new ClassPathResource("META-INF/net.shibboleth.idp/postconfig.xml"),
-                null);        
+                mockProperties);        
     }
     
     /**
@@ -253,7 +254,7 @@ public class DuoAuthnFlowTest extends AbstractAuthnXmlFlowExecutionTests {
      * 
      * @throws IOException on error
      */
-    /*
+    @Test
     public void testDuoAuthnFlowToPasswordlessViewForPasswordlessIntegration() throws IOException {
         
         
@@ -300,7 +301,7 @@ public class DuoAuthnFlowTest extends AbstractAuthnXmlFlowExecutionTests {
         assertFlowExecutionActive();
         assertCurrentStateEquals("PasswordlessView");
     }
-    */
+    
     
     /** Test the Duo flow up to the external authorization request using the dynamically selected
      * first Duo integration.*/

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list