Skip to content

Support cross-origin authentication verification#759

Open
agektmr wants to merge 8 commits into
MasterKale:masterfrom
agektmr:cross-origin
Open

Support cross-origin authentication verification#759
agektmr wants to merge 8 commits into
MasterKale:masterfrom
agektmr:cross-origin

Conversation

@agektmr
Copy link
Copy Markdown
Contributor

@agektmr agektmr commented May 6, 2026

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.

Copy link
Copy Markdown
Owner

@MasterKale MasterKale left a comment

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
Copy link
Copy Markdown
Contributor Author

agektmr commented May 31, 2026

@MasterKale the suggestion looks great. Thank you!

…origin behavior and refine cross-origin error messages
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