webauthn

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCredentialNotFound     = errors.New("credential not found")
	ErrSessionNotFound        = errors.New("session not found")
	ErrDuplicateCredential    = errors.New("credential already registered")
	ErrInvalidWebAuthnPayload = errors.New("invalid webauthn request payload")

	ErrUnexpectedType = errors.New("unexpected type")
)

Functions

func Module

func Module() fx.Option

Types

type AAGUID

type AAGUID []byte //nolint:recvcheck // String on value

func (AAGUID) DeviceName

func (a AAGUID) DeviceName() string

func (*AAGUID) Scan

func (a *AAGUID) Scan(src any) error

Scan implements sql.Scanner.

func (AAGUID) String

func (a AAGUID) String() string

String implements fmt.Stringer.

func (*AAGUID) Value

func (a *AAGUID) Value() (driver.Value, error)

Value implements driver.Valuer.

type Config

type Config struct {
	RPDisplayName string
	RPID          string
	RPOrigins     []string
}

type Credential

type Credential struct {
	ID              int64
	UserID          int64
	CredentialID    []byte
	PublicKey       []byte
	AttestationType string
	Transport       []string
	AAGUID          []byte
	Flags           uint8
	SignCount       uint32
	Name            string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type CredentialID

type CredentialID []byte //nolint:recvcheck // String on value

func (*CredentialID) Scan

func (c *CredentialID) Scan(src any) error

Scan implements sql.Scanner.

func (CredentialID) String

func (c CredentialID) String() string

String implements fmt.Stringer.

func (CredentialID) Value

func (c CredentialID) Value() (driver.Value, error)

Value implements driver.Valuer.

type Repository

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

func NewRepository

func NewRepository(db *bun.DB) *Repository

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, model *credentialModel) error

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, id int64, userID int64) error

func (*Repository) GetByCredentialID

func (r *Repository) GetByCredentialID(ctx context.Context, credentialID []byte) (*Credential, error)

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id int64) (*Credential, error)

func (*Repository) GetByUserID

func (r *Repository) GetByUserID(ctx context.Context, userID int64) ([]Credential, error)

func (*Repository) UpdateName

func (r *Repository) UpdateName(ctx context.Context, id int64, userID int64, name string) error

func (*Repository) UpdateSignCount

func (r *Repository) UpdateSignCount(ctx context.Context, id int64, signCount uint32) error

type Service

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

func NewService

func NewService(
	cfg Config,
	credentials *Repository,
	usersSvc *users.Service,
	backend cache.Cache,
	logger *zap.Logger,
) (*Service, error)

func (*Service) BeginLogin

func (s *Service) BeginLogin(ctx context.Context) (*protocol.CredentialAssertion, error)

func (*Service) BeginRegistration

func (s *Service) BeginRegistration(ctx context.Context, user *users.User) (*protocol.CredentialCreation, error)

func (*Service) DeleteCredential

func (s *Service) DeleteCredential(ctx context.Context, id int64, userID int64) error

func (*Service) FinishLogin

func (s *Service) FinishLogin(ctx context.Context, body []byte) (*users.User, error)

func (*Service) FinishRegistration

func (s *Service) FinishRegistration(ctx context.Context, user *users.User, body []byte) (*Credential, error)

func (*Service) GetCredentials

func (s *Service) GetCredentials(ctx context.Context, userID int64) ([]Credential, error)

func (*Service) RenameCredential

func (s *Service) RenameCredential(ctx context.Context, id int64, userID int64, name string) error

type Transports

type Transports []string

func (*Transports) Scan

func (t *Transports) Scan(src any) error

Scan implements sql.Scanner.

func (*Transports) Value

func (t *Transports) Value() (driver.Value, error)

Value implements driver.Valuer.

Jump to

Keyboard shortcuts

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