[java-idp-plugin-webauthn] branch main updated: Fix issue that removed the Error and Info UI contexts from the reg ctx

Phil Smart philip.smart at jisc.ac.uk
Tue Aug 13 16:24:02 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-webauthn.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-webauthn.git;a=commit;h=8a249e9e21553c60890af2c5a77694589130ba2b

The following commit(s) were added to refs/heads/main by this push:
     new 8a249e9  Fix issue that removed the Error and Info UI contexts from the reg ctx
8a249e9 is described below

commit 8a249e9e21553c60890af2c5a77694589130ba2b
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Tue Aug 13 17:23:59 2024 +0100

    Fix issue that removed the Error and Info UI contexts from the reg ctx
---
 .../impl/PopulateWebAuthnRegistrationContext.java  | 35 ++++++++++++++++++----
 .../authn/webauthn/conf/authn/webauthn.properties  |  4 +--
 2 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/PopulateWebAuthnRegistrationContext.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/PopulateWebAuthnRegistrationContext.java
index 4e909cf..6311b7b 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/PopulateWebAuthnRegistrationContext.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/PopulateWebAuthnRegistrationContext.java
@@ -27,6 +27,8 @@ import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 
 import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnRegistrationContext;
+import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnRegistrationErrorContext;
+import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnRegistrationInformationContext;
 import net.shibboleth.idp.profile.AbstractProfileAction;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.logic.FunctionSupport;
@@ -142,16 +144,37 @@ public class PopulateWebAuthnRegistrationContext extends AbstractProfileAction {
         
         // If we want to remove an existing context, first lookup the context (which may create it, so this is not
         // efficient), then remove it. 
+        WebAuthnRegistrationContext context = null;
         if (removeExistingRegistrationContext.test(profileRequestContext)) {
-            final WebAuthnRegistrationContext context = 
+            final WebAuthnRegistrationContext existingContext = 
                     webAuthnRegistrationContextCreationStrategy.apply(profileRequestContext);
-            context.removeFromParent();
+            if (existingContext != null) {
+                existingContext.removeFromParent();
+                
+                // Now create the new context.
+                context = webAuthnRegistrationContextCreationStrategy.apply(profileRequestContext);
+                
+                // Now find any information or error contexts to reattach to the new context
+                final WebAuthnRegistrationErrorContext oldErrCtx = 
+                        existingContext.getSubcontext(WebAuthnRegistrationErrorContext.class);
+                final WebAuthnRegistrationInformationContext oldInfoCtx = 
+                        existingContext.getSubcontext(WebAuthnRegistrationInformationContext.class);
+                // Remove from the old parent for GC, and attach to new context
+                if (oldErrCtx != null) {
+                    oldErrCtx.removeFromParent();
+                    context.addSubcontext(oldErrCtx);
+                }
+                if (oldInfoCtx != null) {
+                    oldInfoCtx.removeFromParent();
+                    context.addSubcontext(oldInfoCtx);
+                }
+                
+            }
+        } else {        
+            // Now create the context.
+            context = webAuthnRegistrationContextCreationStrategy.apply(profileRequestContext);
         }
         
-        // Now create the context.
-        final WebAuthnRegistrationContext context = 
-                webAuthnRegistrationContextCreationStrategy.apply(profileRequestContext);
-        
         if (context == null) {
             log.error("{} Error creating WebAuthnRegistrationContext", getLogPrefix());
             ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
diff --git a/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/conf/authn/webauthn.properties b/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/conf/authn/webauthn.properties
index 106f601..fa032a2 100644
--- a/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/conf/authn/webauthn.properties
+++ b/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/conf/authn/webauthn.properties
@@ -125,7 +125,7 @@ idp.authn.webauthn.supportedPrincipals = \
 #### Authentication properties
 
 # Which type of flow is supported? Usernameless or passwordless
-#idp.authn.webauthn.usernameless.enabled = true
+#idp.authn.webauthn.usernameless.enabled = false
 
 # Enable this flow to act as a second factor. For example, after a password flow and only requiring a simple user gesture (user presence check)
 #idp.authn.webauthn.2fa.enabled = false
@@ -143,7 +143,7 @@ idp.authn.webauthn.supportedPrincipals = \
 #idp.authn.webauthn.passwordless.signalEventOnNoCredentials = false
 #idp.authn.webauthn.passwordless.noCredentialsEventId = NoRegisteredWebAuthnCredentials
 
-# Should a custom event be built of the userHandle supplied by the authenticator during authentication does not related
+# Should a custom event be built if the userHandle supplied by the authenticator during authentication is not related
 # to any registered credentials? 
 #idp.authn.webauthn.signalEventOnNoCredentialsRegisteredForUserHandle = false
 #idp.authn.webauthn.userHandleNoRegisteredCredentialsEventId = NoCredentialsRegisteredForUserHandle

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


More information about the commits mailing list