[java-idp-plugin-webauthn] branch main updated: JWEBAUTHN-61 - Add a signal to immediately call the WebAuthn registration JS when the registration page loads

Phil Smart philip.smart at jisc.ac.uk
Fri Aug 22 11:51:08 UTC 2025


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=733b040e025d257bcdd413e8b095d19ffe0f7541

The following commit(s) were added to refs/heads/main by this push:
     new 733b040  JWEBAUTHN-61 - Add a signal to immediately call the WebAuthn registration JS when the registration page loads
733b040 is described below

commit 733b040e025d257bcdd413e8b095d19ffe0f7541
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Aug 22 12:51:06 2025 +0100

    JWEBAUTHN-61 - Add a signal to immediately call the WebAuthn
    registration JS when the registration page loads
    
     - Add a injectable predicate to determine if the registration ceremony
    should be invoked on page load
     - Add a conditional to the default registration view template that
    triggers registration on page load iff the predicate evaluates to true.
    
    https://shibboleth.atlassian.net/browse/JWEBAUTHN-61
---
 .../admin/impl/TriggerRegistrationOnLoad.java      | 61 ++++++++++++++++++++++
 .../webauthn-registration-beans.xml                |  4 ++
 .../webauthn-registration-flow.xml                 |  1 +
 .../authn/webauthn/views/webauthn-register.vm      |  4 ++
 4 files changed, 70 insertions(+)

diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/TriggerRegistrationOnLoad.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/TriggerRegistrationOnLoad.java
new file mode 100644
index 0000000..689c8c7
--- /dev/null
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/TriggerRegistrationOnLoad.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed 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 net.shibboleth.idp.plugin.authn.webauthn.admin.impl;
+
+import java.util.function.Predicate;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.PredicateSupport;
+
+/**
+ * Predicate wrapping an injectable predicate, indicating whether the WebAuthn registration ceremony should be 
+ * automatically triggered when the page loads. A value of {@code true} means the ceremony should be invoked on 
+ * load; {@code false} means it should not.
+ * <p>
+ * The view is responsible for acting on this predicate’s outcome. The default value is {@code false}.
+ * </p>
+ */
+public class TriggerRegistrationOnLoad implements Predicate<ProfileRequestContext> {
+    
+    /** The predicate to run. */
+    @Nonnull
+    private Predicate<ProfileRequestContext> triggerPredicate;
+
+    /** Constructor. */
+    public TriggerRegistrationOnLoad() {
+        triggerPredicate = PredicateSupport.alwaysFalse();
+    }
+
+    /**
+     * Set the predicate to determine if the registration ceremony should be triggered on page load.
+     * 
+     * @param predicate the predicate to set.
+     */
+    public void setTriggerPredicate(@Nonnull final Predicate<ProfileRequestContext> predicate) {        
+        triggerPredicate = Constraint.isNotNull(predicate, "Trigger predicate can not be null");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean test(final ProfileRequestContext prc) {
+        return triggerPredicate.test(prc);
+    }
+    
+   
+}
diff --git a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-beans.xml b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-beans.xml
index 72d684f..19208b2 100644
--- a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-beans.xml
+++ b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-beans.xml
@@ -174,6 +174,10 @@
 
     <bean id="CreatePublicKeyCredentialCreationOptions" parent="AbstractWebAuthnRegistrationAction" scope="prototype"
         class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.CreatePublicKeyCredentialCreationOptions"/>
+        
+    <bean id="TriggerRegistrationOnLoad" scope="prototype"
+        class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.TriggerRegistrationOnLoad"
+        p:triggerPredicate="#{getObject('shibboleth.authn.WebAuthn.registration.TriggerRegistrationOnLoad') ?: false}"/>
 
     <bean id="ExtractPublicKeyCredentialAttestationFromFormRequest" parent="AbstractWebAuthnRegistrationAction" scope="prototype"
         class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.ExtractPublicKeyCredentialAttestationFromFormRequest"
diff --git a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-flow.xml b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-flow.xml
index 456675f..091884a 100644
--- a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-flow.xml
+++ b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/admin/webauthn-registration/webauthn-registration-flow.xml
@@ -121,6 +121,7 @@
             <evaluate expression="flowRequestContext.getExternalContext().getNativeResponse()" result="viewScope.response" />
             <evaluate expression="flowRequestContext.getActiveFlow().getApplicationContext().getBean('RegistrationInfoMessageFunction')" result="viewScope.registrationInfoMessageFunction" />
             <evaluate expression="flowRequestContext.getActiveFlow().getApplicationContext().getBean('RegistrationErrorMessageFunction')" result="viewScope.registrationErrorMessageFunction" />
+            <evaluate expression="TriggerRegistrationOnLoad.test(opensamlProfileRequestContext)" result="viewScope.triggerRegistrationOnLoad"/>
         </on-render>
         
        <transition on="finish" to="RegistrationComplete" />
diff --git a/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-register.vm b/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-register.vm
index 7586fe0..538c854 100644
--- a/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-register.vm
+++ b/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-register.vm
@@ -16,6 +16,7 @@
 ## custom - arbitrary object injected by deployer
 ## registrationInfoMessageFunction - function to produce information message for form
 ## registrationErrorMessageFunction - function to produce error message for form
+## triggerRegistrationOnLoad - true if the registration ceremony should be invoked on page load, false otherwise
 ##
 #set ($debug = $environment.getProperty("idp.authn.webauthn.ui.debug", "false"))
 #set ($lastUsed = $environment.getProperty("idp.authn.webauthn.updateLastUsedTime", "false"))
@@ -95,6 +96,9 @@ $response.addHeader("Content-Security-Policy", "default-src 'none'; style-src 's
                      document.getElementById('unsupportedDiv').classList.remove('hidden')
                    } else{
                      initButton();
+                     if ($triggerRegistrationOnLoad) {
+                        register();
+                     }                     
                    }     
                  
                  } catch (e) {

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


More information about the commits mailing list