accept multiple webauthn origins

This commit is contained in:
Jonathan Klabunde Tomer authored and Jonathan Klabunde Tomer committed 2026-09-25 11:41:18 -07:00
1 parent 416dee5762
commit bdf3e1aea1
7 files changed
+19 -12

No files matched your search

+2 -1
View File
@@ -575,6 +575,7 @@ foundationDbMessages:
registrationWebAuthn:
relyingPartyId: example.org
origin: https://example.org
origins:
- https://example.org
challengeTtl: PT2M
userHandleBlindingSecret: secret://registrationWebAuthn.userHandleBlindingSecret
@@ -819,7 +819,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
final TotpManager totpManager = new TotpManager(rateLimitersCluster, config.getRegistrationTotpConfiguration().maxValidationDelay());
final WebAuthnCeremonyManager webAuthnCeremonyManager = new WebAuthnCeremonyManager(
config.getRegistrationWebAuthnConfiguration().relyingPartyId(),
config.getRegistrationWebAuthnConfiguration().origin(),
config.getRegistrationWebAuthnConfiguration().origins(),
config.getRegistrationWebAuthnConfiguration().challengeTtl(),
config.getRegistrationWebAuthnConfiguration().userHandleBlindingSecret().value(),
rateLimitersCluster);
@@ -26,7 +26,10 @@ import java.security.SecureRandom;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisClusterClient;
import org.whispersystems.textsecuregcm.util.HmacUtils;
@@ -39,7 +42,7 @@ public class WebAuthnCeremonyManager {
/// [relying party ID - WebAuthn TR](https://www.w3.org/TR/webauthn/#relying-party-identifier)
private final String rpId;
/// [origin - WebAuthn TR](https://www.w3.org/TR/webauthn/#dom-collectedclientdata-origin)
private final Origin origin;
private final Set<Origin> 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<String> 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(),
@@ -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) {
}
@@ -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);
@@ -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);
}
+2 -1
View File
@@ -580,6 +580,7 @@ foundationDbMessages:
registrationWebAuthn:
relyingPartyId: example.org
origin: https://example.org
origins:
- https://example.org
challengeTtl: PT2M
userHandleBlindingSecret: secret://registrationWebAuthn.userHandleBlindingSecret