[java-idp-plugin-webauthn] branch main updated: Simplify JSON parsing of CreationOptions and RequestOptions

Phil Smart philip.smart at jisc.ac.uk
Mon Mar 18 17:38:05 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=1d3d3636abbe1f86d50d601f0c6992162beb8d0b

The following commit(s) were added to refs/heads/main by this push:
     new 1d3d363  Simplify JSON parsing of CreationOptions and RequestOptions
1d3d363 is described below

commit 1d3d3636abbe1f86d50d601f0c6992162beb8d0b
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Mar 18 17:38:01 2024 +0000

    Simplify JSON parsing of CreationOptions and RequestOptions
    
     - Also add setting for credProps. Enabled.
---
 .../admin/CredentialCreationOptionsParameters.java | 38 ++++++++++++++++
 .../context/WebAuthnRegistrationContext.java       | 33 --------------
 .../CreatePublicKeyCredentialCreationOptions.java  | 36 ++--------------
 .../impl/YubicoWebAuthnAuthenticationClient.java   |  7 ++-
 .../CreatePublicKeyCredentialRequestOptions.java   | 34 +--------------
 .../authn/webauthn/impl/WebAuthnEncoder.java       | 50 ++++++++++++++++++++++
 .../webauthn-registration-beans.xml                |  3 +-
 .../idp/flows/authn/WebAuthn/webauthn-beans.xml    |  3 +-
 .../idp/flows/authn/WebAuthn/webauthn-flow.xml     |  1 +
 .../plugin/authn/webauthn/views/webauthn-authn.vm  |  7 +--
 .../authn/webauthn/views/webauthn-register.vm      |  6 +--
 11 files changed, 108 insertions(+), 110 deletions(-)

diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java
index 1d00ad8..20b65af 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java
@@ -58,6 +58,9 @@ public class CredentialCreationOptionsParameters extends BaseOptionsParameters {
     
     /** The Attestation conveyance preference.*/
     @Nonnull private final AttestationConveyancePreference attestationConveyancePreference;
+    
+    /** Enable the credential properties extenions. For example, to report discoverable credentials i.e. 'passkeys'.*/
+    private final boolean enableCredProperties;
 
     /**
      * 
@@ -77,6 +80,7 @@ public class CredentialCreationOptionsParameters extends BaseOptionsParameters {
         this.authenticatorAttachment = builder.authenticatorAttachment;
         this.attestationConveyancePreference = Constraint.isNotNull(builder.attestationConveyancePreference, 
                 "AttestationConveyancePreference can not be null");
+        this.enableCredProperties = builder.enableCredProperties;
     }
 
     /**
@@ -128,6 +132,15 @@ public class CredentialCreationOptionsParameters extends BaseOptionsParameters {
         return userId;
     }
     
+    /**
+     * Is the credential properties extension enabled?
+     * 
+     * @return is credential properties extension enabled
+     */
+    public boolean isEnableCredProperties() {
+        return enableCredProperties;
+    }
+    
     /**
      * Get the attestation conveyance preference.
      * 
@@ -246,6 +259,15 @@ public class CredentialCreationOptionsParameters extends BaseOptionsParameters {
          * @return the next stage
          */
         public IBuildStage withAuthenticatorAttachment(@Nullable AuthenticatorAttachment authenticatorAttachment);
+        
+        /**
+         * Is the credential properties extension enabled?
+         * 
+         * @param credProps the flag
+         * 
+         * @return the next stage
+         */
+        public IBuildStage withCredentialPropertiesExt(final boolean credProps);
 
         /**
          * Build the options.
@@ -284,9 +306,16 @@ public class CredentialCreationOptionsParameters extends BaseOptionsParameters {
         
         /** The Attestation conveyance preference.*/
         private AttestationConveyancePreference attestationConveyancePreference;
+        
+        /** 
+         * Enable the credential properties extenions. For example, to report discoverable credentials i.e. 
+         * 'passkeys'.
+         */
+        private boolean enableCredProperties;
 
         /** Constructor.*/
         private Builder() {
+            enableCredProperties = false;
         }
 
         @Override
@@ -336,17 +365,26 @@ public class CredentialCreationOptionsParameters extends BaseOptionsParameters {
             return this;
         }
 
+        @Override
+        public IBuildStage withCredentialPropertiesExt(final boolean credProps) {
+            enableCredProperties = credProps;
+            return this;
+        }
+
         @Override
         public IBuildStage withAuthenticatorAttachment(
                 @Nullable final AuthenticatorAttachment authenticatorAttachment) {
             this.authenticatorAttachment = authenticatorAttachment;
             return this;
         }
+        
 
         @Override
         public CredentialCreationOptionsParameters build() {
             return new CredentialCreationOptionsParameters(this);
         }
+
+
     }
    
 }
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
index 883c97f..54d88db 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
@@ -24,23 +24,12 @@ public final class WebAuthnRegistrationContext extends BaseWebAuthnContext {
     /** The original username. */
     @Nullable private String username;
     
-    /** In a new context? TODO. But for now an existing credId if found.*/
-    @Deprecated
-    @Nullable private byte[] existingCredentialId;
-    
-    /** In a new context? TODO. The existing credential public key encoded in COSE_Key format if found.*/
-    @Deprecated
-    @Nullable private byte[] existingPublicKey;    
-    
     /** An assertion response that is the result of an authentication.*/
     @Nullable private PublicKeyCredential<AuthenticatorAttestationResponse, ClientRegistrationExtensionOutputs> 
         authenticatorAttestationResponse;
     
     /** The public key credential creation options for registration.*/ 
     @Nullable private PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions;
-    
-    /** The public key credential creation options for registration represented as a JSON string.*/ 
-    @Nullable private String publicKeyCredentialCreationOptionsJSON;
            
     /** 
      * The credential public key which is the result of registration of a new key pair generated
@@ -156,28 +145,6 @@ public final class WebAuthnRegistrationContext extends BaseWebAuthnContext {
         return registrationResult;
     }
     
-    /**
-     * Get the credential public key registration options in JSON format.
-     * 
-     * @return the publicKeyCredentialCreationOptions in JSON format.
-     */
-    @Nullable public String getPublicKeyCredentialCreationOptionsJSON() {
-        return publicKeyCredentialCreationOptionsJSON;
-    }
-    
-    /**
-     * Set the credential public key registration options in JSON format.
-     * 
-     * @param optionsJSON The publicKeyCredentialCreationOptions in JSON to set.
-     * 
-     * @return this context
-     */
-    @Nonnull public WebAuthnRegistrationContext setPublicKeyCredentialCreationOptionsJSON(final String optionsJSON) {
-        publicKeyCredentialCreationOptionsJSON = optionsJSON;
-        return this;
-    }
-
-    
     /**
      * Set the display friendly nickname for this credential.
      * 
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java
index 127b164..35a9666 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java
@@ -26,8 +26,6 @@ import org.opensaml.profile.action.EventIds;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.yubico.webauthn.data.AttestationConveyancePreference;
 import com.yubico.webauthn.data.PublicKeyCredentialCreationOptions;
 import com.yubico.webauthn.data.PublicKeyCredentialDescriptor;
@@ -39,9 +37,6 @@ import net.shibboleth.idp.plugin.authn.webauthn.admin.WebAuthnRegistrationEventI
 import net.shibboleth.idp.plugin.authn.webauthn.client.WebAuthnAuthenticationClient;
 import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnRegistrationContext;
 import net.shibboleth.idp.plugin.authn.webauthn.exception.WebAuthnAuthenticationClientException;
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 import net.shibboleth.shared.primitive.LoggerFactory;
 
@@ -57,31 +52,7 @@ import net.shibboleth.shared.primitive.LoggerFactory;
 public class CreatePublicKeyCredentialCreationOptions extends AbstractWebAuthnRegistrationAction {
     
     /** Class logger. */
-    @Nonnull private final Logger log = LoggerFactory.getLogger(CreatePublicKeyCredentialCreationOptions.class);
-    
-    //TODO move out where we do this
-    /** The JSON object mapper used to JSONify webauthn objects. */
-    @NonnullAfterInit private ObjectMapper objectMapper;
-    
-    /** {@inheritDoc} */
-    @Override
-    protected void doInitialize() throws ComponentInitializationException {
-        super.doInitialize();
-        
-        if (objectMapper == null) {
-            throw new ComponentInitializationException("JSON Object Mapper can not be null");
-        }
-    }
-    
-    /**
-     * Set the JSON object mapper to use.
-     * 
-     * @param mapper The jsonObjectMapper to set.
-     */
-    public void setObjectMapper(@Nonnull final ObjectMapper mapper) {
-        checkSetterPreconditions();
-        objectMapper = Constraint.isNotNull(mapper, "JSON Object Mapper can not be null");
-    }       
+    @Nonnull private final Logger log = LoggerFactory.getLogger(CreatePublicKeyCredentialCreationOptions.class);     
     
     @Override
     protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
@@ -144,6 +115,7 @@ public class CreatePublicKeyCredentialCreationOptions extends AbstractWebAuthnRe
                     .withAttestationConveyancePreference(attestationPreference)
                     .withAuthenticatorAttachment(
                             context.getAuthenticatorAttachmentRequirement())
+                    .withCredentialPropertiesExt(true)
                     .build();
 
             assert creationOptions != null;
@@ -151,11 +123,9 @@ public class CreatePublicKeyCredentialCreationOptions extends AbstractWebAuthnRe
                     getWebAuthnClient().createRegistrationRequest(creationOptions);
             
             context.setPublicKeyCredentialCreationOptions(pkCredCreationOptions);
-            //convert to JSON for the JS API to use
-            context.setPublicKeyCredentialCreationOptionsJSON(objectMapper.writeValueAsString(pkCredCreationOptions));
             
             log.debug("{} Created PublicKeyCredentialCreationOptions '{}'",getLogPrefix(), pkCredCreationOptions);
-        } catch (final WebAuthnAuthenticationClientException | JsonProcessingException | ConstraintViolationException e) {
+        } catch (final WebAuthnAuthenticationClientException | ConstraintViolationException e) {
             log.error("{} Unable to generate PublicKeyCredentialCreationOptions",getLogPrefix(), e);
             ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
             return;
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java
index ba0c48a..b76f216 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java
@@ -124,7 +124,12 @@ public class YubicoWebAuthnAuthenticationClient implements WebAuthnAuthenticatio
                     .build();
         
         // Request Credential Properties extension, allows knowledge if key is resident or passkey
-        final RegistrationExtensionInputs extensions = RegistrationExtensionInputs.builder().credProps().build();
+        RegistrationExtensionInputs extensions;
+        if (creationOptions.isEnableCredProperties()) {
+            extensions = RegistrationExtensionInputs.builder().credProps().build();
+        } else {
+            extensions = RegistrationExtensionInputs.builder().build();
+        }
         
         final PublicKeyCredentialCreationOptions creation = PublicKeyCredentialCreationOptions.builder()
                     .rp(rp.getIdentity())
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CreatePublicKeyCredentialRequestOptions.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CreatePublicKeyCredentialRequestOptions.java
index e98a9e9..abf5522 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CreatePublicKeyCredentialRequestOptions.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CreatePublicKeyCredentialRequestOptions.java
@@ -26,8 +26,6 @@ import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.yubico.webauthn.data.PublicKeyCredentialDescriptor;
 import com.yubico.webauthn.data.PublicKeyCredentialRequestOptions;
 import com.yubico.webauthn.data.UserVerificationRequirement;
@@ -39,10 +37,7 @@ import net.shibboleth.idp.plugin.authn.webauthn.client.WebAuthnAuthenticationCli
 import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnAuthenticationContext;
 import net.shibboleth.idp.plugin.authn.webauthn.exception.WebAuthnAuthenticationClientException;
 import net.shibboleth.idp.plugin.authn.webauthn.storage.CredentialRegistration;
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.primitive.LoggerFactory;
 
 /**
@@ -57,31 +52,6 @@ public class CreatePublicKeyCredentialRequestOptions extends AbstractWebAuthnAut
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(CreatePublicKeyCredentialRequestOptions.class);
     
-    //TODO move out where we do this
-    /** The JSON object mapper used to JSONify webauthn objects. */
-    @NonnullAfterInit private ObjectMapper objectMapper;
-    
-    /** {@inheritDoc} */
-    @Override
-    protected void doInitialize() throws ComponentInitializationException {
-        super.doInitialize();
-        
-        if (objectMapper == null) {
-            throw new ComponentInitializationException("JSON Object Mapper can not be null");
-        }
-    }
-    
-    
-    /**
-     * Set the JSON object mapper to use.
-     * 
-     * @param mapper The jsonObjectMapper to set.
-     */
-    public void setObjectMapper(@Nonnull final ObjectMapper mapper) {
-        checkSetterPreconditions();
-        objectMapper = Constraint.isNotNull(mapper, "JsonObjectMapper can not be null");
-    }  
-    
     @Override
     protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
             @Nonnull final AuthenticationContext authenticationContext, 
@@ -120,11 +90,9 @@ public class CreatePublicKeyCredentialRequestOptions extends AbstractWebAuthnAut
                     client.createAuthenticationRequest(requestParams);
             
             context.setPublicKeyCredentialRequestOptions(pkCredRequestOptions);
-            // Convert to JSON for the view. TODO maybe that should be converted by velocity etc.
-            context.setPublicKeyCredentialRequestOptionsJSON(objectMapper.writeValueAsString(pkCredRequestOptions));
             
             log.debug("{} Created PublicKeyCredentialRequestOptions: '{}'",getLogPrefix(), pkCredRequestOptions);
-        } catch (final WebAuthnAuthenticationClientException | JsonProcessingException e) {
+        } catch (final WebAuthnAuthenticationClientException e) {
             log.error("{} Unable to generate PublicKeyCredentialRequestOptions",getLogPrefix(), e);
             ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.AUTHN_EXCEPTION);
             return;
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
index b12c3ea..8e23e93 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
@@ -24,21 +24,71 @@ import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.yubico.webauthn.RegisteredCredential;
 import com.yubico.webauthn.data.AuthenticatorTransport;
+import com.yubico.webauthn.data.PublicKeyCredentialCreationOptions;
+import com.yubico.webauthn.data.PublicKeyCredentialRequestOptions;
 
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
 
 /**
  * Encoder for {@link RegisteredCredential credentials} that converts raw values into a format suitable for views.
  */
 public final class WebAuthnEncoder {
+    
+    /** Class logger. */
+    @Nonnull private static final Logger LOG = LoggerFactory.getLogger(WebAuthnEncoder.class);
    
     /** Private constructor. */
     private WebAuthnEncoder() {
         
     }
     
+    /**
+     * Serialize the PublicKeyCredentialOptions request into a JSON string.
+     * 
+     * @param options the options to serialize
+     * 
+     * @return the JSON serialized PublicKeyCredentialOptions, or an empty string if there is an error 
+     *          converting the string.
+     */
+    public static String serializePublicKeyCredentialOptionsAsJSON(
+            @Nullable final PublicKeyCredentialCreationOptions options) {
+        if (options != null) {
+            try {
+                return options.toCredentialsCreateJson();
+            } catch (final JsonProcessingException e) {
+                LOG.debug("Unable to serialize PublicKeyCredentialOptions", e);
+            }
+        }
+        return "";
+        
+    }
+    
+    /**
+     * Serialize the PublicKeyCredentialRequestOptions request into a JSON string.
+     * 
+     * @param options the options to serialize
+     * 
+     * @return the JSON serialized PublicKeyCredentialRequestOptions, or an empty string if there is an error 
+     *          converting the string.
+     */
+    public static String serializePublicKeyCredentialRequestOptionsAsJSON(
+            @Nullable final PublicKeyCredentialRequestOptions options) {
+        if (options != null) {
+            try {
+                return options.toCredentialsGetJson();
+            } catch (final JsonProcessingException e) {
+                LOG.debug("Unable to serialize PublicKeyCredentialOptions", e);
+            }
+        }
+        return "";
+    }
+    
     /**
      * Format the given instant into a display friendly string.
      * 
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 ce418d5..fe8b0db 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
@@ -75,8 +75,7 @@
         class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.AddUserId" />
 
     <bean id="CreatePublicKeyCredentialCreationOptions" parent="AbstractWebAuthnRegistrationAction"
-        class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.CreatePublicKeyCredentialCreationOptions"
-        p:objectMapper-ref="shibboleth.authn.WebAuthn.JSONObjectMapper" />
+        class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.CreatePublicKeyCredentialCreationOptions"/>
 
     <bean id="ExtractAuthenticatorAttestationFromFormRequest" parent="AbstractWebAuthnRegistrationAction"
         class="net.shibboleth.idp.plugin.authn.webauthn.admin.impl.ExtractAuthenticatorAttestationFromFormRequest"
diff --git a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-beans.xml b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-beans.xml
index d476edd..d2625ae 100644
--- a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-beans.xml
+++ b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-beans.xml
@@ -84,8 +84,7 @@
         p:webAuthnBaseContextLookupStrategy-ref="shibboleth.ChildLookup.WebAuthnAuthenticationContextFromAuthenticationContext" />
 
     <bean id="CreatePublicKeyCredentialRequestOptions" parent="AbstractWebAuthnAuthenticationAction"
-        class="net.shibboleth.idp.plugin.authn.webauthn.impl.CreatePublicKeyCredentialRequestOptions"
-        p:objectMapper-ref="shibboleth.authn.WebAuthn.JSONObjectMapper" />
+        class="net.shibboleth.idp.plugin.authn.webauthn.impl.CreatePublicKeyCredentialRequestOptions"/>
 
     <bean id="ExtractAuthenticatorAssertionFromFormRequest" parent="AbstractWebAuthnAuthenticationAction"
         class="net.shibboleth.idp.plugin.authn.webauthn.impl.ExtractAuthenticatorAssertionFromFormRequest"
diff --git a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-flow.xml b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-flow.xml
index b3f52ae..b10bd24 100644
--- a/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-flow.xml
+++ b/webauthn-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/WebAuthn/webauthn-flow.xml
@@ -109,6 +109,7 @@
             <evaluate expression="flowRequestContext.getActiveFlow().getApplicationContext().getBean('WebAuthnCSPDigester')" result="requestScope.cspDigester" />
             <evaluate expression="flowRequestContext.getActiveFlow().getApplicationContext().getBean('WebAuthnCSPNonce')" result="requestScope.cspNonce" />   
             <evaluate expression="T(net.shibboleth.shared.codec.HTMLEncoder)" result="viewScope.encoder" />
+            <evaluate expression="T(net.shibboleth.idp.plugin.authn.webauthn.impl.WebAuthnEncoder)" result="viewScope.webAuthnEncoder"/>
             <evaluate expression="flowRequestContext.getExternalContext().getNativeRequest()" result="viewScope.request" />
             <evaluate expression="flowRequestContext.getExternalContext().getNativeResponse()" result="viewScope.response" />
         </on-render>
diff --git a/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-authn.vm b/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-authn.vm
index db58167..3d9c1b7 100644
--- a/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-authn.vm
+++ b/webauthn-impl/src/main/resources/net/shibboleth/idp/plugin/authn/webauthn/views/webauthn-authn.vm
@@ -12,6 +12,7 @@
 ## authenticationWarningContext - context with login warning state
 ## rpUIContext - the context with SP UI information from the metadata
 ## encoder - HTMLEncoder class
+## webAuthnEncoder - WebAuthnEncoder class
 ## request - HttpServletRequest
 ## response - HttpServletResponse
 ## environment - Spring Environment object for property resolution
@@ -46,8 +47,8 @@
                 } catch (e) {
                     // No issue if this does not work
                 }            
-                var pkCredRequestOptions = $webauthnContext.publicKeyCredentialRequestOptionsJSON;
-                var parsedRequestOptions = parseRequestOptionsFromJSON({ publicKey: pkCredRequestOptions });
+                var pkCredRequestOptions = $webAuthnEncoder.serializePublicKeyCredentialRequestOptionsAsJSON($webauthnContext.publicKeyCredentialRequestOptions)
+                var parsedRequestOptions = parseRequestOptionsFromJSON(pkCredRequestOptions);
                 #if($debug == "true")
                     console.log("Raw request options", pkCredRequestOptions);
                     console.log("Parsed request options", parsedRequestOptions);
@@ -136,7 +137,7 @@
                             "Request Options")</label>
                             <textarea id="publicKeyCredentialRequestOptions" name="publicKeyCredentialRequestOptions"
                                 rows="20" cols="50">
-                            $webauthnContext.publicKeyCredentialRequestOptionsJSON</textarea>
+                            $webAuthnEncoder.serializePublicKeyCredentialRequestOptionsAsJSON($webauthnContext.publicKeyCredentialRequestOptions)</textarea>
                         </div>
                     #end
                     
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 751808a..7172575 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
@@ -37,8 +37,8 @@
          
          async function register() {  
              clearMessages();            
-             var pkCredOptions = $webauthnRegContext.publicKeyCredentialCreationOptionsJSON; 
-             var pkCredOptionsParsed = parseCreationOptionsFromJSON({ publicKey: pkCredOptions }); 
+             var pkCredOptions = $webAuthnEncoder.serializePublicKeyCredentialOptionsAsJSON($webauthnRegContext.publicKeyCredentialCreationOptions); 
+             var pkCredOptionsParsed = parseCreationOptionsFromJSON(pkCredOptions); 
              #if($debug == "true")
                  console.log("Raw creation options", pkCredOptions);
                  console.log("Parsed creation options", pkCredOptionsParsed);
@@ -182,7 +182,7 @@
                       <div class="debug" id="debug-div">
                          <label for="publicKeyCredentialCreation">#springMessageText("idp.webauthn.register.debug.registration", "Registration Options")</label>
                          <textarea id="publicKeyCredentialCreation" name="publicKeyCredentialCreation" rows="20" cols="50">
-                         $webauthnRegContext.publicKeyCredentialCreationOptionsJSON</textarea>                   
+                         $webAuthnEncoder.serializePublicKeyCredentialOptionsAsJSON($webauthnRegContext.publicKeyCredentialCreationOptions)</textarea>                   
                       </div>
                   #end            
                </div>

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


More information about the commits mailing list