[java-idp-plugin-webauthn] branch main updated: Fix failure result when credential not added

Phil Smart philip.smart at jisc.ac.uk
Fri Sep 20 10:07:51 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=ef9ddc9d95d46874fef754d71f315b7dae50a6d5

The following commit(s) were added to refs/heads/main by this push:
     new ef9ddc9  Fix failure result when credential not added
ef9ddc9 is described below

commit ef9ddc9d95d46874fef754d71f315b7dae50a6d5
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Sep 20 11:07:48 2024 +0100

    Fix failure result when credential not added
---
 .../authn/webauthn/admin/impl/StorePublicKeyCredential.java    | 10 +++++++++-
 .../storage/impl/IdPStorageServiceCredentialRespository.java   |  5 +++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java
index 8acca09..f7a7177 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java
@@ -145,7 +145,15 @@ public class StorePublicKeyCredential extends AbstractWebAuthnAuditingAction<Web
                     .withUserVerified(registrationResult.isUserVerified())
                     .build();
             
-            repository.addRegistrationByUsername(username, registration);  
+            final boolean added = repository.addRegistrationByUsername(username, registration);  
+            
+            if (!added) {
+                log.error("{} Unable to store registration for key '{}'",getLogPrefix(), 
+                        registrationResult.getKeyId().getId().getBase64Url());
+                ActionSupport.buildEvent(profileRequestContext, WebAuthnRegistrationEventIds.INVALID_REGISTRATION);
+                auditFailure(profileRequestContext, "credential-added");
+                return;
+            }
             
             if (log.isInfoEnabled()) {
             
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java
index 41ab9c5..c90bc91 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java
@@ -60,8 +60,9 @@ import net.shibboleth.shared.primitive.LoggerFactory;
 /**
  * A {@link CredentialRepository} adaptor for the Shibboleth {@link StorageService}.
  * 
- * <p>Username (user.name) is used as the key to the storage context. The object to store (value of the storage record) 
- * is a set of {@link CredentialRegistration registered credentials}. Storage records do not expire.</p>
+ * <p>The IdP username (which might have been canonicalized by this point) is used as the key to the storage context. 
+ * The object to store (value of the storage record) is a set of {@link CredentialRegistration registered credentials}. 
+ * Storage records do not expire.</p>
  * 
  * <p>Note, any exception is wrapped in an unchecked {@link CredentialRepositoryException}. If the caller does not deem 
  * this terminal, they should catch and handle that error appropriately.</p>

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


More information about the commits mailing list