Skip to content

Commit 6cdbfa3

Browse files
Spomkyclaude
andauthored
fix: pass topOriginValidator to CheckTopOrigin in requestCeremony() (#821)
* fix: pass topOriginValidator to CheckTopOrigin in requestCeremony() The custom TopOriginValidator set via enableTopOriginValidator() was only passed to CheckTopOrigin in creationCeremony() but not in requestCeremony(), causing the fallback HostTopOriginValidator to always be used during authentication. This broke cross-origin iframe scenarios where topOrigin differs from the host. Fixes #816 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: make enableTopOriginValidator actually enable the validation Previously, CheckTopOrigin always validated the top origin using a fallback HostTopOriginValidator when no custom validator was set. This made enableTopOriginValidator() misleading since validation was always active regardless. Now, when no TopOriginValidator is configured, the top origin check is skipped entirely. Calling enableTopOriginValidator() truly enables the validation, matching the method's name and intent. Fixes #816 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8ee7654 commit 6cdbfa3

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/webauthn/src/CeremonyStep/CeremonyStepManagerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function requestCeremony(): CeremonyStepManager
169169
$this->allowSubdomains,
170170
$this->securedRelyingPartyId ?? []
171171
),
172-
new CheckTopOrigin(),
172+
new CheckTopOrigin($this->topOriginValidator),
173173
new CheckRelyingPartyIdIdHash(),
174174
new CheckUserWasPresent(),
175175
new CheckUserVerification(),

src/webauthn/src/CeremonyStep/CheckTopOrigin.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ public function process(
3333
throw AuthenticatorResponseVerificationException::create('The response is not cross-origin.');
3434
}
3535
if ($this->topOriginValidator === null) {
36-
(new HostTopOriginValidator($host))->validate($topOrigin);
37-
} else {
38-
$this->topOriginValidator->validate($topOrigin);
36+
return;
3937
}
38+
$this->topOriginValidator->validate($topOrigin);
4039
}
4140
}

0 commit comments

Comments
 (0)