Documentation
¶
Overview ¶
Package passkey manages WebAuthn passkey registration and authentication.
Index ¶
- Variables
- type Attempt
- type AttemptGuard
- type Authentication
- type AuthenticationStarted
- type Ceremony
- type CeremonyHash
- type CeremonyType
- type CompleteInput
- type Config
- type Credential
- type EventType
- type Manager
- func (manager *Manager) BeginAuthentication(ctx context.Context) (AuthenticationStarted, error)
- func (manager *Manager) BeginRegistration(ctx context.Context, subjectID string) (RegistrationStarted, error)
- func (manager *Manager) CompleteAuthentication(ctx context.Context, input CompleteInput) (Authentication, error)
- func (manager *Manager) CompleteRegistration(ctx context.Context, input CompleteInput) (Credential, error)
- func (manager *Manager) List(ctx context.Context, subjectID string) ([]Credential, error)
- func (manager *Manager) Remove(ctx context.Context, subjectID string, credentialID []byte, sourceKey string) error
- type Operation
- type RegistrationStarted
- type SecurityEvent
- type SecurityEventSink
- type Store
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrAttemptBlocked = errors.New("passkey attempt blocked") ErrConflict = errors.New("passkey conflict") ErrInactiveCeremony = errors.New("passkey ceremony is inactive") ErrInvalidCeremony = errors.New("invalid or expired passkey ceremony") ErrInvalidConfig = errors.New("invalid passkey configuration") ErrInvalidInput = errors.New("invalid passkey input") ErrInvalidRecord = errors.New("invalid passkey record") ErrLastCredential = errors.New("cannot remove the last sign-in method") ErrNotFound = errors.New("passkey record not found") ErrVerification = errors.New("passkey verification failed") )
Functions ¶
This section is empty.
Types ¶
type AttemptGuard ¶
type Authentication ¶
type AuthenticationStarted ¶
type AuthenticationStarted struct {
Token string
Options *protocol.CredentialAssertion
ExpiresAt time.Time
}
type Ceremony ¶
type Ceremony struct {
Type CeremonyType
TokenHash CeremonyHash
SubjectID string
Session webauthnlibrary.SessionData
CreatedAt time.Time
ExpiresAt time.Time
}
type CeremonyHash ¶
type CeremonyType ¶
type CeremonyType string
const ( CeremonyRegistration CeremonyType = "registration" CeremonyAuthentication CeremonyType = "authentication" )
type CompleteInput ¶
type Config ¶
type Config struct {
RelyingPartyID string
RelyingPartyName string
Origins []string
CeremonyLifetime time.Duration
AttemptGuard AttemptGuard
SecurityEvents SecurityEventSink
Now func() time.Time
}
type Credential ¶
type Credential = webauthnlibrary.Credential
type EventType ¶
type EventType string
const ( EventRegistered EventType = "passkey_registered" EventRegistrationFailed EventType = "passkey_registration_failed" EventAuthenticated EventType = "passkey_authenticated" EventAuthenticationFailed EventType = "passkey_authentication_failed" EventCloneWarning EventType = "passkey_clone_warning" EventRemoved EventType = "passkey_removed" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) BeginAuthentication ¶
func (manager *Manager) BeginAuthentication(ctx context.Context) (AuthenticationStarted, error)
func (*Manager) BeginRegistration ¶
func (*Manager) CompleteAuthentication ¶
func (manager *Manager) CompleteAuthentication( ctx context.Context, input CompleteInput, ) (Authentication, error)
func (*Manager) CompleteRegistration ¶
func (manager *Manager) CompleteRegistration( ctx context.Context, input CompleteInput, ) (Credential, error)
type RegistrationStarted ¶
type RegistrationStarted struct {
Token string
Options *protocol.CredentialCreation
ExpiresAt time.Time
}
type SecurityEvent ¶
type SecurityEventSink ¶
type SecurityEventSink interface {
Record(ctx context.Context, event SecurityEvent)
}
type Store ¶
type Store interface {
FindUserBySubject(ctx context.Context, subjectID string) (User, error)
FindUserByCredential(ctx context.Context, credentialID, userHandle []byte) (User, error)
CreateCeremony(ctx context.Context, ceremony Ceremony) error
FindCeremony(ctx context.Context, ceremonyHash CeremonyHash) (Ceremony, error)
CompleteRegistration(
ctx context.Context,
ceremonyHash CeremonyHash,
subjectID string,
credential Credential,
completedAt time.Time,
) error
CompleteAuthentication(
ctx context.Context,
ceremonyHash CeremonyHash,
subjectID string,
previous Credential,
updated Credential,
completedAt time.Time,
) error
DeleteCredential(ctx context.Context, subjectID string, credentialID []byte, deletedAt time.Time) error
}
Store keeps complete credential records, consumes ceremonies with credential writes, and preserves another sign-in method when deleting a credential.
type User ¶
type User struct {
SubjectID string
Handle []byte
Name string
DisplayName string
Credentials []Credential
}
func (User) WebAuthnCredentials ¶
func (user User) WebAuthnCredentials() []Credential