From bdf3e1aea1b83e6ce14530ba515501c15bade3ad Mon Sep 17 00:00:00 2001 From: Jonathan Klabunde Tomer Date: Fri, 25 Sep 2026 09:30:20 -0700 Subject: [PATCH] accept multiple webauthn origins --- service/config/sample.yml | 3 ++- .../textsecuregcm/WhisperServerService.java | 2 +- .../auth/webauthn/WebAuthnCeremonyManager.java | 13 ++++++++----- .../configuration/WebAuthnConfiguration.java | 4 +++- .../textsecuregcm/workers/CommandDependencies.java | 2 +- .../auth/webauthn/WebAuthnCeremonyManagerTest.java | 4 ++-- service/src/test/resources/config/test.yml | 3 ++- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/service/config/sample.yml b/service/config/sample.yml index 7eafddb03..2330e4723 100644 --- a/service/config/sample.yml +++ b/service/config/sample.yml @@ -575,6 +575,7 @@ foundationDbMessages: registrationWebAuthn: relyingPartyId: example.org - origin: https://example.org + origins: + - https://example.org challengeTtl: PT2M userHandleBlindingSecret: secret://registrationWebAuthn.userHandleBlindingSecret diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index 0a3886a57..a644623da 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -819,7 +819,7 @@ public class WhisperServerService extends Application origins; private final byte[] blindingSecret; private final Duration challengeTtl; @@ -56,10 +59,10 @@ public class WebAuthnCeremonyManager { private static final SecureRandom SECURE_RANDOM = new SecureRandom(); - public WebAuthnCeremonyManager(final String rpId, final String origin, final Duration challengeTtl, final byte[] blindingSecret, + public WebAuthnCeremonyManager(final String rpId, final List origins, final Duration challengeTtl, final byte[] blindingSecret, final FaultTolerantRedisClusterClient challengeStorageCluster) { this.rpId = rpId; - this.origin = new Origin(origin); + this.origins = origins.stream().map(Origin::new).collect(Collectors.toSet()); this.challengeTtl = challengeTtl; this.blindingSecret = blindingSecret; this.challengeStorageCluster = challengeStorageCluster; @@ -128,7 +131,7 @@ public class WebAuthnCeremonyManager { // we aren't verifying any signatures for registration, so we don't need to bother saving a // challenge; accept whatever is supplied .challenge(registrationData.getCollectedClientData().getChallenge()) - .origin(origin) + .origins(origins) .rpId(rpId) .build(); @@ -202,7 +205,7 @@ public class WebAuthnCeremonyManager { final byte[] credentialId = matchingCredential.getAttestedCredentialData().getCredentialId(); final AuthenticationParameters authenticationParameters = new AuthenticationParameters( ServerProperty.builder() - .origin(origin) + .origins(origins) .rpId(rpId) .challenge(() -> challenge) .build(), diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/WebAuthnConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/WebAuthnConfiguration.java index 08ba2db45..51137e158 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/WebAuthnConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/WebAuthnConfiguration.java @@ -6,14 +6,16 @@ package org.whispersystems.textsecuregcm.configuration; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import java.time.Duration; +import java.util.List; import org.whispersystems.textsecuregcm.configuration.secrets.SecretBytes; import org.whispersystems.textsecuregcm.util.ExactlySize; public record WebAuthnConfiguration( @NotBlank String relyingPartyId, - @NotBlank String origin, + @NotEmpty List<@NotBlank String> origins, @NotNull Duration challengeTtl, @NotNull @ExactlySize(32) SecretBytes userHandleBlindingSecret) { } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/workers/CommandDependencies.java b/service/src/main/java/org/whispersystems/textsecuregcm/workers/CommandDependencies.java index df83d404e..95bec7b9c 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/workers/CommandDependencies.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/workers/CommandDependencies.java @@ -385,7 +385,7 @@ public record CommandDependencies( configuration.getRegistrationTotpConfiguration().maxValidationDelay()); final WebAuthnCeremonyManager webAuthnCeremonyManager = new WebAuthnCeremonyManager( configuration.getRegistrationWebAuthnConfiguration().relyingPartyId(), - configuration.getRegistrationWebAuthnConfiguration().origin(), + configuration.getRegistrationWebAuthnConfiguration().origins(), configuration.getRegistrationWebAuthnConfiguration().challengeTtl(), configuration.getRegistrationWebAuthnConfiguration().userHandleBlindingSecret().value(), rateLimitersCluster); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/auth/webauthn/WebAuthnCeremonyManagerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/auth/webauthn/WebAuthnCeremonyManagerTest.java index 6eaa15510..31f2dcdd2 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/auth/webauthn/WebAuthnCeremonyManagerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/auth/webauthn/WebAuthnCeremonyManagerTest.java @@ -52,8 +52,8 @@ class WebAuthnCeremonyManagerTest { @BeforeEach void setUp() { - webAuthnCeremonyManager = new WebAuthnCeremonyManager(RP_ID, ORIGIN, CHALLENGE_TTL, TestRandomUtil.nextBytes(32), - REDIS_CLUSTER_EXTENSION.getRedisCluster()); + webAuthnCeremonyManager = new WebAuthnCeremonyManager(RP_ID, List.of(ORIGIN), CHALLENGE_TTL, + TestRandomUtil.nextBytes(32), REDIS_CLUSTER_EXTENSION.getRedisCluster()); helper = new WebAuthnTestHelper(RP_ID, ORIGIN, EmulatorUtil.NONE_ATTESTATION_AUTHENTICATOR); } diff --git a/service/src/test/resources/config/test.yml b/service/src/test/resources/config/test.yml index d8c198bff..dd88c4d9d 100644 --- a/service/src/test/resources/config/test.yml +++ b/service/src/test/resources/config/test.yml @@ -580,6 +580,7 @@ foundationDbMessages: registrationWebAuthn: relyingPartyId: example.org - origin: https://example.org + origins: + - https://example.org challengeTtl: PT2M userHandleBlindingSecret: secret://registrationWebAuthn.userHandleBlindingSecret