defaultstore

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package defaultstore implements the SQL-backed default store for the totp plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultTOTPStore

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

DefaultTOTPStore implements totptypes.Store using a SQL database.

Supports PostgreSQL, MySQL, and SQLite through dialect-specific sqlc-generated queries. Safe for concurrent use.

func NewDefaultTOTPStore

func NewDefaultTOTPStore(db *sql.DB, dialect plugins.Dialect) (*DefaultTOTPStore, error)

NewDefaultTOTPStore creates a DefaultTOTPStore for the given dialect. The dialect switch happens exactly once here; all store methods call through the querier interface and are dialect-agnostic.

func (*DefaultTOTPStore) DeleteSessionVerification

func (s *DefaultTOTPStore) DeleteSessionVerification(ctx context.Context, sessionID string) error

DeleteSessionVerification clears one session's verification.

func (*DefaultTOTPStore) DeleteUserSessionVerifications

func (s *DefaultTOTPStore) DeleteUserSessionVerifications(ctx context.Context, userID string) error

DeleteUserSessionVerifications clears every session verification for a user.

func (*DefaultTOTPStore) GetCredential

func (s *DefaultTOTPStore) GetCredential(ctx context.Context, userID string) (totptypes.Credential, error)

GetCredential returns the user's TOTP credential.

func (*DefaultTOTPStore) IsSessionVerified

func (s *DefaultTOTPStore) IsSessionVerified(ctx context.Context, sessionID, userID string, since time.Time) (bool, error)

IsSessionVerified reports whether the session was verified after since.

func (*DefaultTOTPStore) MarkSessionVerified

func (s *DefaultTOTPStore) MarkSessionVerified(ctx context.Context, sessionID, userID string, at time.Time) error

MarkSessionVerified records a verified session.

func (*DefaultTOTPStore) SetCredential

func (s *DefaultTOTPStore) SetCredential(ctx context.Context, userID string, secret *string, enabled bool) error

SetCredential writes the credential; a nil secret clears it.

Jump to

Keyboard shortcuts

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