Skip to content

Support cross-origin authentication verification#759

Merged
MasterKale merged 8 commits into
MasterKale:masterfrom
agektmr:cross-origin
Jun 19, 2026
Merged

Support cross-origin authentication verification#759
MasterKale merged 8 commits into
MasterKale:masterfrom
agektmr:cross-origin

Conversation

@agektmr

@agektmr agektmr commented May 6, 2026

Copy link
Copy Markdown
Contributor

To support cross-origin authentication on SimpleWebAuthn, this pull request adds the following to the verifyAuthenticationResponse.ts:

  • Add a new expectedTopOrigin property to the options
  • Check if crossOrigin is true or false
  • Check if topOrigin meets the expectation

Comment thread packages/server/src/authentication/verifyAuthenticationResponse.ts Outdated
Comment thread packages/server/src/authentication/verifyAuthenticationResponse.ts Outdated
}
});

Deno.test('should NOT check topOrigin when crossOrigin is false', async () => {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is an interesting one. According to the spec, topOrigin should only be set if crossOrigin is true:

It is set only if the call was made from context that is not same-origin with its ancestors, i.e. if crossOrigin is true.

https://w3c.github.io/webauthn/#dom-collectedclientdata-toporigin

Based on this I'd actually make the new code error out if crossOrigin is false but there's a topOrigin defined in clientDataJSON 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Please have a look.

@MasterKale MasterKale left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agektmr I'm so sorry for taking so long to respond. I think this PR is really close to getting merged. I had a few proposed changes I'd like you to consider first.

Comment thread packages/server/src/authentication/verifyAuthenticationResponse.ts
@MasterKale MasterKale added the package:server @simplewebauthn/server label May 27, 2026
…e.ts

Co-authored-by: Matthew Miller <matthew@millerti.me>
@agektmr

agektmr commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

@MasterKale the suggestion looks great. Thank you!

…origin behavior and refine cross-origin error messages
@MasterKale MasterKale added this to the v14.0.0 milestone Jun 19, 2026

@MasterKale MasterKale left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, this looks great. I want to roll this out as a new feautre with the v14.0.0 milestone (https://github.com/MasterKale/SimpleWebAuthn/milestone/54) so please bear with me as I coordinate development of another feature or two before rolling this out 🙇‍♂️

@MasterKale MasterKale merged commit 59cb967 into MasterKale:master Jun 19, 2026
4 checks passed
MasterKale added a commit that referenced this pull request Jun 19, 2026
This reverts commit 59cb967, reversing
changes made to bf10ba0.

I've merged these changes into the milestone/v14.0.0 branch instead via #773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:server @simplewebauthn/server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants