Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate registration options #4

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

MasterKale
Copy link
Collaborator

@MasterKale MasterKale commented Aug 9, 2024

This PR fleshes out the GET /registration/options endpoint to support the following options as query params:

  • userName (Required): String
  • userID (Optional): base64url string of bytes (defaults to random ID generated by SimpleWebAuthn)
  • userVerification (Optional): Either 'discouraged', 'preferred', or 'required' (defaults to 'preferred')
  • attestation (Optional): Either 'none' or 'direct' (defaults to 'none')
  • attachment (Optional): Either 'cross-platform' or 'platform'
  • algES256 (Optional): Boolean (defaults to true)
  • algRS256 (Optional): Boolean (defaults to true)
  • discoverableCredential (Optional): Either 'discouraged', 'preferred', or 'required' (defaults to 'required')

Screenshot 2024-08-10 at 11 50 17 AM

@MasterKale
Copy link
Collaborator Author

MasterKale commented Aug 9, 2024

Tests are broken because of an issue with module resolution in @cloudflare/vitest-pool-workers. They don't like imports of folders with an index.js file (e.g. errors/index.js) as "./errors". This is currently manifesting as any import of SimpleWebAuthn breaking test execution (the test environment doesn't like the @peculiar libraries in particular.)

See here:

cloudflare/workers-sdk#6286 (comment)

What's annoying is that the code is otherwise fine - it executes as expected when hitting http://localhost:8787/registration/options. It's only the testing environment that's having problems 😞

@MasterKale
Copy link
Collaborator Author

Oh nice upgrading @cloudflare/[email protected] fixed the tests 🎉

@MasterKale MasterKale requested a review from timcappalli August 10, 2024 18:48
@MasterKale
Copy link
Collaborator Author

@timcappalli I'm curious what you think about this as a direction for the API to go. I basically modeled it after what's on https://webauthn.io. There's still some things missing (sessions to store challenges for, persistence of challenges, etc...) but I want to make sure this is good so far before I merge it and move on.

const opts = await generateRegistrationOptions({
rpID: RP_ID,
rpName: RP_NAME,
userName,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
userName,
userName: username,

This threw me being case sensitive and wasn't expecting a capital N

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants