[java-idp-plugin-webauthn] branch main updated: JWEBAUTHN-22 - Support for different usernames in key registration
Phil Smart
philip.smart at jisc.ac.uk
Mon Sep 16 10:33:34 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=08acbe2d0fa913f6bc41384281bad05a03c4afe1
The following commit(s) were added to refs/heads/main by this push:
new 08acbe2 JWEBAUTHN-22 - Support for different usernames in key registration
08acbe2 is described below
commit 08acbe2d0fa913f6bc41384281bad05a03c4afe1
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Sep 16 11:33:32 2024 +0100
JWEBAUTHN-22 - Support for different usernames in key registration
- Add IdP username to credential storage record for searching over
https://shibboleth.atlassian.net/browse/JWEBAUTHN-22
---
.../webauthn/storage/CredentialRegistration.java | 48 +++++++++++++++++++---
.../admin/impl/StorePublicKeyCredential.java | 1 +
2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRegistration.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRegistration.java
index dd69865..8134a71 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRegistration.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRegistration.java
@@ -51,6 +51,9 @@ public final class CredentialRegistration {
/** The users identity. */
@Nonnull private final UserIdentity userIdentity;
+
+ /** The username of the user to the IdP.*/
+ @Nonnull private final String username;
/** An optional nickname of the credential. */
@Nullable private final String credentialNickname;
@@ -84,6 +87,7 @@ public final class CredentialRegistration {
*/
private CredentialRegistration(final Builder builder) {
this.userIdentity = builder.userIdentity;
+ this.username = builder.username;
this.transports = builder.transports;
this.registrationTime = builder.registrationTime;
this.credential = builder.credential;
@@ -135,12 +139,24 @@ public final class CredentialRegistration {
}
/**
- * Get the name of the user identity registered.
+ * Get the username of the user to the IdP.
+ *
+ * @return the user's username
+ */
+ @JsonGetter("username")
+ @Nonnull public String getUsername() {
+ final String name = username;
+ assert name != null;
+ return name;
+ }
+
+ /**
+ * Get the WebAuthn user.name of the user identity registered.
*
* @return the name of the user identity
*/
@JsonIgnore
- @Nonnull public String getUsername() {
+ @Nonnull public String getWebAuthnUserName() {
final String name = userIdentity.getName();
assert name != null;
return name;
@@ -248,6 +264,7 @@ public final class CredentialRegistration {
public CredentialRegistration withCredential(@Nonnull final RegisteredCredential newRegisteredCred) {
return CredentialRegistration.builder()
.withUserIdentity(userIdentity)
+ .withUsername(username)
.withTransports(transports)
.withRegistrationTime(registrationTime)
// The credential here is the new one
@@ -273,7 +290,18 @@ public final class CredentialRegistration {
* @param userIdentity the users identity
* @return the next builder stage
*/
- @Nonnull public ITransportsStage withUserIdentity(@Nonnull final UserIdentity userIdentity);
+ @Nonnull public IUsernameStage withUserIdentity(@Nonnull final UserIdentity userIdentity);
+ }
+
+ /** Builder stage.*/
+ public interface IUsernameStage {
+ /**
+ * The username of the user to the IdP.
+ *
+ * @param username the username of the user
+ * @return the next builder stage
+ */
+ @Nonnull public ITransportsStage withUsername(@Nonnull final String username);
}
/** Builder stage.*/
@@ -354,9 +382,12 @@ public final class CredentialRegistration {
/** Builder.*/
@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "with")
public static final class Builder
- implements IUserIdentityStage, ITransportsStage, IRegistrationTimeStage, ICredentialStage, IBuildStage {
+ implements IUserIdentityStage,IUsernameStage, ITransportsStage, IRegistrationTimeStage, ICredentialStage,
+ IBuildStage {
/** The users identity.*/
@Nonnull private UserIdentity userIdentity;
+ /** The username of the user to the IdP.*/
+ @Nonnull private String username;
/** The transports.*/
@Nonnull private SortedSet<AuthenticatorTransport> transports;
/** The credential registration time .*/
@@ -383,10 +414,17 @@ public final class CredentialRegistration {
@Override
@JsonProperty("userIdentity")
- @Nonnull public ITransportsStage withUserIdentity(@Nonnull final UserIdentity user) {
+ @Nonnull public IUsernameStage withUserIdentity(@Nonnull final UserIdentity user) {
userIdentity = Constraint.isNotNull(user, "UserIdentity can not be null");
return this;
}
+
+ @Override
+ @JsonProperty("username")
+ @Nonnull public ITransportsStage withUsername(@Nonnull final String name) {
+ username = Constraint.isNotNull(name, "Username can not be null");
+ return this;
+ }
@Override
@JsonProperty("transports")
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 6b94af8..1cb874e 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
@@ -135,6 +135,7 @@ public class StorePublicKeyCredential extends AbstractWebAuthnAuditingAction<Web
final CredentialRegistration registration = CredentialRegistration.builder()
.withUserIdentity(user)
+ .withUsername(username)
.withTransports(registrationResult.getKeyId().getTransports().orElse(new TreeSet<>()))
.withRegistrationTime(now)
.withCredential(credential)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list