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

fix: add MFA for WebAuthn bindings #960

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix: add MFA for WebAuthn bindings #960

wants to merge 2 commits into from

Conversation

J0
Copy link
Contributor

@J0 J0 commented Sep 19, 2024

What kind of change does this PR introduce?

We introduce bindings for MFA (WebAuthn) which consists of primary methods and helper methods.

Core Methods

The core methods have single step and multi-step use. A single step enroll handles the browser interactions for you while the multi-step enroll provides one the freedom to configure options as they wish.

For enrollment single step looks like:

await supabase.auth. enroll({factorType: 'webauthn'})

While mutli-step enroll contains a webAuthn parameter than can be customized

enroll(factorType: 'webauthn, webAuthn{...}`)

Verify operates in a similar fashion.

There are two methods, challenge and challengeAndVerify which are affected.

Helper methods

We provide the following helper methods for ease of use:

  1. browserSupportsWebAuthn - most modern browsers should support the WebAuthn specification.
  2. startRegistration - this method takes reference from SimpleWebAuthn and wraps navigator.create. Use this to customize how a credential is created
  3. startAuthentication - this methods takes reference from SimpleWebAuthn and wraps navigator.get. Use this to customize how a credential is retrieved

src/lib/types.ts Outdated Show resolved Hide resolved
src/GoTrueClient.ts Outdated Show resolved Hide resolved
src/lib/types.ts Show resolved Hide resolved
src/lib/types.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Show resolved Hide resolved
@J0 J0 marked this pull request as ready for review October 2, 2024 14:18
src/lib/types.ts Outdated Show resolved Hide resolved
src/lib/types.ts Outdated Show resolved Hide resolved
src/GoTrueClient.ts Show resolved Hide resolved
src/lib/helpers.ts Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/helpers.ts Outdated Show resolved Hide resolved
@J0 J0 force-pushed the j0/add_webauthn branch from 15e4b56 to f26d43e Compare October 9, 2024 09:51
src/lib/helpers.ts Outdated Show resolved Hide resolved
src/lib/types.ts Outdated Show resolved Hide resolved
src/lib/types.ts Outdated Show resolved Hide resolved
@J0 J0 force-pushed the j0/add_webauthn branch from f26d43e to 32f44a1 Compare October 10, 2024 14:32
@J0 J0 force-pushed the j0/add_webauthn branch from 3a6f8b0 to 6ebce44 Compare October 21, 2024 16:27

export type MFAVerifySingleStepWebAuthnParams = {
factorId: string
challengeId: string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
challengeId: string
challengeId?: string

return { data, error: null }
}
const factorId = data.id
const webAuthn = this._getWebAuthnRpDetails()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should pre-emptively check if web-authn is supported here and return an error if not.

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