[java-idp-plugin-duo] branch main updated: JDUO-80 - Use of Duo as a Passwordless solution

Scott Cantor cantor.2 at osu.edu
Wed Jan 10 15:55:48 UTC 2024


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

scantor 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=92f2327cef177d9c1ece9433b9f3a8728151a16e

The following commit(s) were added to refs/heads/main by this push:
     new 92f2327c JDUO-80 - Use of Duo as a Passwordless solution
92f2327c is described below

commit 92f2327cef177d9c1ece9433b9f3a8728151a16e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jan 10 10:55:21 2024 -0500

    JDUO-80 - Use of Duo as a Passwordless solution
    
    https://shibboleth.atlassian.net/browse/JDUO-80
    
    Adjust populate action to ensure a new Duo context each time.
---
 .../duo/impl/PopulateDuoAuthenticationContext.java | 30 ++-----------------
 .../impl/PopulateDuoAuthenticationContextTest.java | 34 +---------------------
 2 files changed, 4 insertions(+), 60 deletions(-)

diff --git a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContext.java b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContext.java
index e7651698..91020c3f 100644
--- a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContext.java
+++ b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContext.java
@@ -68,9 +68,6 @@ public class PopulateDuoAuthenticationContext extends AbstractAuthenticationActi
     
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(PopulateDuoAuthenticationContext.class);
-    
-    /** Strategy used to locate or create the {@link DuoOIDCAuthenticationContext} to populate. */
-    @Nonnull private Function<ProfileRequestContext,DuoOIDCAuthenticationContext> duoAuthContextCreationStrategy;
 
     /** Strategy used to locate a {@link DuoPasswordlessContext} if present. */
     @Nonnull private Function<ProfileRequestContext,DuoPasswordlessContext> passwordlessContextLookupStrategy;
@@ -92,11 +89,6 @@ public class PopulateDuoAuthenticationContext extends AbstractAuthenticationActi
     
     /** Constructor.*/
     public PopulateDuoAuthenticationContext() {
-        //default creates duo authentication context under authentication context.
-        duoAuthContextCreationStrategy =
-                new ChildContextLookup<>(DuoOIDCAuthenticationContext.class, true).compose(
-                        new ChildContextLookup<>(AuthenticationContext.class));
-        
         passwordlessContextLookupStrategy =
                 new ChildContextLookup<>(DuoPasswordlessContext.class).compose(
                         new ChildContextLookup<>(AuthenticationContext.class));
@@ -143,19 +135,6 @@ public class PopulateDuoAuthenticationContext extends AbstractAuthenticationActi
                 + " creation strategy cannot be null");
     }
     
-    /**
-     * Set the strategy used to create/locate the {@link DuoOIDCAuthenticationContext} to operate on.
-     * 
-     * @param strategy creation strategy
-     */
-    public void setDuoContextCreationStrategy(
-            @Nonnull final Function<ProfileRequestContext,DuoOIDCAuthenticationContext> strategy) {
-        checkSetterPreconditions();
-
-        duoAuthContextCreationStrategy = Constraint.isNotNull(strategy, "DuoAuthenticationContext"
-                + " creation strategy cannot be null");
-    }
-    
     /**
      * Set the strategy used to locate the {@link DuoPasswordlessContext} to operate on.
      * 
@@ -219,12 +198,9 @@ public class PopulateDuoAuthenticationContext extends AbstractAuthenticationActi
             return;
         }
 
-        final DuoOIDCAuthenticationContext duoContext = duoAuthContextCreationStrategy.apply(profileRequestContext);
-        if (duoContext == null) {
-            log.error("{} Error creating DuoAuthenticationContext", getLogPrefix());
-            ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
-            return;
-        }
+        // Create new Duo context and ensure it replaces any existing one.
+        final DuoOIDCAuthenticationContext duoContext = new DuoOIDCAuthenticationContext();
+        authenticationContext.addSubcontext(duoContext, true);
         
         final DuoPasswordlessContext passwordlessContext =
                 passwordlessContextLookupStrategy.apply(profileRequestContext);
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContextTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContextTest.java
index 6b37df43..f6d2b5e9 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContextTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/PopulateDuoAuthenticationContextTest.java
@@ -433,36 +433,4 @@ public class PopulateDuoAuthenticationContextTest extends AbstractDuoActionTest
         assertEventId(event, EventIds.INVALID_PROFILE_CTX);
     }
     
-    /**
-     * Test unsuccessful execution if there is no Duo Context.
-     * 
-     * @throws ComponentInitializationException on error.
-     * @throws DuoClientException on error.
-     * @throws DuoRegistryException on error.
-     */
-    @Test
-    public void testExecuteNoDuoContext() throws ComponentInitializationException, 
-            DuoRegistryException, DuoClientException {
-        final DefaultDuoOIDCIntegration integ = createDummyDuoIntegration();
-        integ.initialize();
-
-        //set the duo integration strategy to lookup this 
-        action.setStandardDuoIntegrationLookupStrategy(prc -> integ);
-        //lookup a username
-        action.setUsernameLookupStrategy(prc -> "jdoe");
-        action.setRedirectURICreationStrategy((http,duoInteg) 
-                -> "https://example.com/idp/profile/Authn/Duo/2FA/callback");
-        action.setDuoContextCreationStrategy(prc -> null);
-        
-        action.setHttpServletRequestSupplier(new ConstantSupplier<>(request));
-        
-        final DuoOIDCClientRegistry mockClientRegistry = Mockito.mock(DuoOIDCClientRegistry.class);
-
-
-        action.setClientRegistry(mockClientRegistry);
-        action.initialize();
-        final Event event = action.execute(src);
-        assertEventId(event, EventIds.INVALID_PROFILE_CTX);
-    }
-
-}
+}
\ No newline at end of file

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


More information about the commits mailing list