passkeys

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SQLite      = Dialect{Now: "CURRENT_TIMESTAMP", RowID: "id", StartedAlt: "created_at", TimeArgs: true}
	SQLiteRowID = Dialect{Now: "CURRENT_TIMESTAMP", RowID: "rowid", StartedAlt: "expires_at", TimeArgs: true, TagStartedAt: true}
	MySQL       = Dialect{Now: "NOW()", RowID: "id", StartedAlt: "created_at", TagStartedAt: true}
)
View Source
var ErrRejected = errors.New("passkey not recognised")

Functions

This section is empty.

Types

type Dialect

type Dialect struct {
	Now          string
	RowID        string
	StartedAlt   string
	TimeArgs     bool
	TagStartedAt bool
}

type Handlers

type Handlers struct {
	Svc          *Service
	Tag          string
	SettingsURL  string
	ClientIP     func(r *http.Request) string
	LoadUser     func(id int64) (LoginUser, error)
	Start2FA     func(w http.ResponseWriter, r *http.Request, u LoginUser) (string, error)
	IssueSession func(w http.ResponseWriter, r *http.Request, u LoginUser) (dest string, code string, err error)
	CurrentUser  func(r *http.Request) (id int64, email string, ok bool)
	Record       func(r *http.Request, userID int64, action, detail string)
	Flash        func(w http.ResponseWriter, r *http.Request, kind, key string)
}

func (*Handlers) AddBegin

func (h *Handlers) AddBegin(w http.ResponseWriter, r *http.Request)

func (*Handlers) AddFinish

func (h *Handlers) AddFinish(w http.ResponseWriter, r *http.Request)

func (*Handlers) Delete

func (h *Handlers) Delete(w http.ResponseWriter, r *http.Request)

func (*Handlers) LoginBegin

func (h *Handlers) LoginBegin(w http.ResponseWriter, r *http.Request)

func (*Handlers) LoginFinish

func (h *Handlers) LoginFinish(w http.ResponseWriter, r *http.Request)

func (*Handlers) SessionRevoke

func (h *Handlers) SessionRevoke(w http.ResponseWriter, r *http.Request)

type Info

type Info struct {
	ID         int64
	Name       string
	CreatedAt  time.Time
	LastUsedAt sql.NullTime
}

type LoginUser

type LoginUser struct {
	ID       int64
	Is2FA    bool
	Disabled bool
	Raw      any
}

type Service

type Service struct {
	DB          func() *sql.DB
	DisplayName string
	Dialect     Dialect
	Revoke      func(ctx context.Context, userID int64, sid string) error
}

func (*Service) BeginLogin

func (s *Service) BeginLogin(r *http.Request) (*protocol.CredentialAssertion, string, error)

func (*Service) BeginRegistration

func (s *Service) BeginRegistration(r *http.Request, userID int64, email string) (*protocol.CredentialCreation, error)

func (*Service) Delete

func (s *Service) Delete(userID, id int64) error

func (*Service) FinishLogin

func (s *Service) FinishLogin(r *http.Request, token string) (int64, error)

func (*Service) FinishRegistration

func (s *Service) FinishRegistration(r *http.Request, userID int64, email, name string) error

func (*Service) List

func (s *Service) List(userID int64) ([]Info, error)

func (*Service) ListSessions

func (s *Service) ListSessions(userID int64, currentRefresh string) ([]SessionInfo, error)

func (*Service) RevokeSession

func (s *Service) RevokeSession(userID, id int64) error

func (*Service) TagSession

func (s *Service) TagSession(refreshToken, location, userAgent string)

type SessionInfo

type SessionInfo struct {
	ID        int64
	Location  string
	UserAgent string
	StartedAt time.Time
	Current   bool
}

func (SessionInfo) Device

func (si SessionInfo) Device() string

Jump to

Keyboard shortcuts

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