Documentation
¶
Overview ¶
Package passkey provides an opt-in Better Auth-shaped WebAuthn plugin.
Index ¶
- Constants
- func New(config Config) (betterauth.Plugin, error)
- type AuthenticationConfig
- type AuthenticationVerification
- type AuthenticatorAttachment
- type Config
- type ExtensionsResolver
- type Passkey
- type RegistrationConfig
- type RegistrationResolution
- type RegistrationUser
- type RegistrationVerification
- type ResidentKey
- type UserVerification
Constants ¶
const (
// ModelPasskey is the logical adapter model contributed by this plugin.
ModelPasskey = "passkey"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthenticationConfig ¶
type AuthenticationConfig struct {
AfterVerification func(*betterauth.HookContext, AuthenticationVerification) error
Extensions ExtensionsResolver
}
AuthenticationConfig controls authentication-only compatibility hooks.
type AuthenticationVerification ¶
type AuthenticationVerification struct {
UserID string
CredentialID string
NewCounter uint32
BackedUp bool
ClientData map[string]any
}
AuthenticationVerification is public-safe data for an application callback after assertion verification and before counter/session persistence.
type AuthenticatorAttachment ¶
type AuthenticatorAttachment string
AuthenticatorAttachment optionally limits registration to platform or cross-platform authenticators.
const ( AuthenticatorPlatform AuthenticatorAttachment = "platform" AuthenticatorCrossPlatform AuthenticatorAttachment = "cross-platform" )
type Config ¶
type Config struct {
RPID string
RPDisplayName string
Origins []string
ChallengeTTL time.Duration
ChallengeCookie string
UserVerification UserVerification
ResidentKey ResidentKey
AuthenticatorAttachment AuthenticatorAttachment
RequireResidentKey bool
MaxCredentials int
Schema betterauth.ModelSchema
Registration RegistrationConfig
Authentication AuthenticationConfig
}
Config is immutable after New. RPID and Origins are explicit so a proxy or request header can never expand the WebAuthn relying-party boundary.
type ExtensionsResolver ¶
type ExtensionsResolver func(*betterauth.HookContext) (map[string]any, error)
ExtensionsResolver returns WebAuthn client extension inputs for one request. It must be concurrency-safe and must not retain HookContext.
type Passkey ¶
type Passkey struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
PublicKey string `json:"publicKey"`
UserID string `json:"userId"`
CredentialID string `json:"credentialID"`
Counter uint32 `json:"counter"`
DeviceType string `json:"deviceType"`
BackedUp bool `json:"backedUp"`
Transports string `json:"transports,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
AAGUID string `json:"aaguid,omitempty"`
// contains filtered or unexported fields
}
Passkey is the Better Auth-compatible public credential record. The opaque WebAuthn user handle and complete verifier record are never serialized.
type RegistrationConfig ¶
type RegistrationConfig struct {
AllowWithoutSession bool
ResolveUser func(*betterauth.HookContext, string) (RegistrationUser, error)
AfterVerification func(
*betterauth.HookContext,
RegistrationVerification,
) (RegistrationResolution, error)
Extensions ExtensionsResolver
}
RegistrationConfig controls registration-only compatibility hooks.
type RegistrationResolution ¶
RegistrationResolution may rebind a sessionless verified registration and supply a default label. A session-authenticated registration cannot be rebound to another user.
type RegistrationUser ¶
RegistrationUser is the account bound to a registration ceremony.
type RegistrationVerification ¶
type RegistrationVerification struct {
User RegistrationUser
Context string
CredentialID string
AAGUID string
DeviceType string
BackedUp bool
ClientData map[string]any
}
RegistrationVerification is public-safe data for an application callback after cryptographic verification and before credential persistence.
type ResidentKey ¶
type ResidentKey string
ResidentKey controls discoverable-credential creation.
const ( ResidentKeyRequired ResidentKey = "required" ResidentKeyPreferred ResidentKey = "preferred" ResidentKeyDiscouraged ResidentKey = "discouraged" )
type UserVerification ¶
type UserVerification string
UserVerification controls whether an authenticator must verify the user.
const ( VerificationRequired UserVerification = "required" VerificationPreferred UserVerification = "preferred" )