Passkeys.
Usernameless passkey sign-up and sign-in, with the session cookie set for you.
Go
pk, _ := passkey.New(svc, store, passkey.Config{
RPID: "tensile.example", RPName: "Example", Origins: []string{"https://tensile.example"},
})Sign-up starts with an app-chosen binding, such as a random value in a short-lived cookie, and carries the form’s data in State:
Go
opts, err := pk.BeginFirstRegistration(ctx, userID, passkey.User{Name: email, Label: "This device", State: formJSON}, binding)
// …the browser client runs the ceremony and posts the credential…
cred, proof, err := pk.FinishRegistration(ctx, binding, body)
res, err := authhttp.SignIn(w, r, svc, proof, auth.StartOptions{Scopes: scopes}) // cred.State is formJSONSign-in is usernameless:
Go
opts, err := pk.BeginLogin(ctx, passkey.LoginOptions{Conditional: autofill})
proof, err := pk.FinishLogin(ctx, body)
res, err := authhttp.SignIn(w, r, svc, proof, auth.StartOptions{Scopes: scopesFor(proof.User)})authhttp.SignIn sets the session cookie, with the device label (“Chrome on macOS”) and user agent from the request. A passkey needs nothing more.