passkeys

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package passkeys is the official WebAuthn passkey plugin of Auth-All.

A signed-in user registers passkeys, lists them, and deletes them. Anyone signs in with a passkey through a discoverable ceremony, so the browser offers the passkeys it holds and no address is named. The plugin verifies every response with github.com/go-webauthn/webauthn.

A sign-in with the user-verified flag issues the session at once, because the device proved two factors. A sign-in without the flag runs the TOTP challenge of a user with a confirmed second factor, as every other first factor does.

The plugin owns two tables. Migrate creates them.

Index

Constants

View Source
const (
	// VerificationRequired refuses an authenticator that cannot check a PIN
	// or a biometric.
	VerificationRequired = "required"
	// VerificationPreferred asks for a check and accepts an authenticator
	// without one. It is the default.
	VerificationPreferred = "preferred"
	// VerificationDiscouraged asks the authenticator to skip the check.
	VerificationDiscouraged = "discouraged"
)

User verification requirements.

View Source
const DefaultFreshAge = 10 * time.Minute

DefaultFreshAge is the default maximum age of a session that registers or deletes a passkey.

View Source
const ID = "passkey"

ID is the plugin identifier. It is also the session method of a passkey sign-in.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Plugin)

Option configures the plugin.

func FreshAge

func FreshAge(d time.Duration) Option

FreshAge sets the maximum age of a session that registers or deletes a passkey. An older session gets 403 SESSION_NOT_FRESH. The default is DefaultFreshAge.

func Origins

func Origins(origins ...string) Option

Origins sets the origins that a response may come from, for example "https://app.example.com". The default is the origin of the base URL.

func RPDisplayName

func RPDisplayName(name string) Option

RPDisplayName sets the name that the browser shows during a ceremony. The default is the RP ID.

func RPID

func RPID(id string) Option

RPID sets the relying party ID, which is the registrable domain that every passkey binds to, for example "example.com". The default is the host of the base URL. A passkey of one RP ID never works under another, so the value must stay the same for the life of the application.

func UserVerification

func UserVerification(v string) Option

UserVerification sets the user verification requirement of both ceremonies: VerificationRequired, VerificationPreferred, or VerificationDiscouraged. The default is VerificationPreferred.

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin is the passkeys plugin.

func New

func New(opts ...Option) *Plugin

New returns the passkeys plugin.

func (*Plugin) Cleanup

func (p *Plugin) Cleanup(ctx context.Context) (int, error)

Cleanup removes the ceremonies that expired more than one hour ago. The host calls it on its own schedule, because Auth-All runs no background work.

func (*Plugin) Delete

func (p *Plugin) Delete(ctx context.Context, userID, passkeyID string) error

Delete removes one passkey of one user. It returns NOT_FOUND when the user holds no passkey with that identifier.

func (*Plugin) ID

func (p *Plugin) ID() string

ID implements plugin.Plugin.

func (*Plugin) List

func (p *Plugin) List(ctx context.Context, userID string) ([]store.Passkey, error)

List returns every passkey of one user, and the newest comes first.

func (*Plugin) Register

func (p *Plugin) Register(r *plugin.Registry) error

Register implements plugin.Plugin.

Directories

Path Synopsis
Package passkeystest provides a virtual WebAuthn authenticator for Go tests.
Package passkeystest provides a virtual WebAuthn authenticator for Go tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL