MCPcopy Index your code
hub / github.com/supabase/auth / PasskeyAuthenticationOptions

Method PasskeyAuthenticationOptions

internal/api/passkey_authentication.go:33–65  ·  view source on GitHub ↗

PasskeyAuthenticationOptions handles POST /passkeys/authentication/options. Generates WebAuthn authentication options for discoverable credential login.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

31// PasskeyAuthenticationOptions handles POST /passkeys/authentication/options.
32// Generates WebAuthn authentication options for discoverable credential login.
33func (a *API) PasskeyAuthenticationOptions(w http.ResponseWriter, r *http.Request) error {
34 config := a.config
35 db := a.db.WithContext(r.Context())
36
37 webAuthn, err := a.getPasskeyWebAuthn()
38 if err != nil {
39 return apierrors.NewInternalServerError("Failed to initialize WebAuthn").WithInternalError(err)
40 }
41
42 // Discoverable flow: empty allowCredentials, no user binding
43 options, session, err := webAuthn.BeginDiscoverableLogin()
44 if err != nil {
45 return apierrors.NewInternalServerError("Failed to generate WebAuthn authentication options").WithInternalError(err)
46 }
47
48 expiresAt := time.Now().Add(config.WebAuthn.ChallengeExpiryDuration)
49 challenge := models.NewWebAuthnChallenge(
50 nil, // no user_id for discoverable flow
51 models.WebAuthnChallengeTypeAuthentication,
52 &models.WebAuthnSessionData{SessionData: session},
53 expiresAt,
54 )
55
56 if err := db.Create(challenge); err != nil {
57 return apierrors.NewInternalServerError("Database error storing challenge").WithInternalError(err)
58 }
59
60 return sendJSON(w, http.StatusOK, &PasskeyAuthenticationOptionsResponse{
61 ChallengeID: challenge.ID.String(),
62 Options: &options.Response,
63 ExpiresAt: expiresAt.Unix(),
64 })
65}
66
67// PasskeyAuthenticationVerify handles POST /passkeys/authentication/verify.
68// Validates the WebAuthn assertion and issues tokens for discoverable credential login.

Callers

nothing calls this directly

Calls 9

getPasskeyWebAuthnMethod · 0.95
NewInternalServerErrorFunction · 0.92
NewWebAuthnChallengeFunction · 0.92
sendJSONFunction · 0.85
WithContextMethod · 0.80
NowMethod · 0.80
AddMethod · 0.65
WithInternalErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected