consoleauth

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FailurePurposeLogin   = "login"
	FailurePurposePairing = "pairing"
)
View Source
const (
	RoleAdmin = "admin"
	RoleUser  = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FailureLimiter

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

func NewFailureLimiter

func NewFailureLimiter(maxFailures int, lockout time.Duration, opts ...FailureLimiterOption) *FailureLimiter

func (*FailureLimiter) Allow

func (l *FailureLimiter) Allow(purpose, role, remoteKey string) (bool, time.Time)

func (*FailureLimiter) RecordFailure

func (l *FailureLimiter) RecordFailure(purpose, role, remoteKey string) time.Time

func (*FailureLimiter) RecordSuccess

func (l *FailureLimiter) RecordSuccess(purpose, role, remoteKey string)

type FailureLimiterOption

type FailureLimiterOption func(*FailureLimiter)

func WithLimiterNow

func WithLimiterNow(now func() time.Time) FailureLimiterOption

type Option

type Option func(*Store)

func WithNow

func WithNow(now func() time.Time) Option

func WithRandomReader

func WithRandomReader(reader io.Reader) Option

type PairingCode

type PairingCode struct {
	Code      string     `json:"code"`
	Role      string     `json:"role"`
	CreatedAt time.Time  `json:"created_at"`
	ExpiresAt time.Time  `json:"expires_at"`
	UsedAt    *time.Time `json:"used_at,omitempty"`
}

type Session

type Session struct {
	ID            string     `json:"id"`
	Role          string     `json:"role"`
	CreatedAt     time.Time  `json:"created_at"`
	LastSeen      time.Time  `json:"last_seen"`
	ExpiresAt     time.Time  `json:"expires_at"`
	UserAgentHint string     `json:"user_agent_hint,omitempty"`
	RevokedAt     *time.Time `json:"revoked_at,omitempty"`
}

type Store

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

func NewStore

func NewStore(workspaceDir string, opts ...Option) *Store

func (*Store) ConsumePairingCode

func (s *Store) ConsumePairingCode(code string) (PairingCode, bool, error)

func (*Store) CreatePairingCode

func (s *Store) CreatePairingCode(role string, ttl time.Duration) (PairingCode, error)

func (*Store) CreateSession

func (s *Store) CreateSession(role, userAgentHint string, ttl time.Duration) (Session, error)

func (*Store) HasPassword

func (s *Store) HasPassword(role string) (bool, error)

func (*Store) RevokeRoleSessions

func (s *Store) RevokeRoleSessions(role string) error

func (*Store) RevokeSession

func (s *Store) RevokeSession(id string) error

func (*Store) SetPassword

func (s *Store) SetPassword(role, password string) error

func (*Store) ValidateSession

func (s *Store) ValidateSession(id string) (Session, bool, error)

func (*Store) VerifyPassword

func (s *Store) VerifyPassword(role, password string) (bool, error)

type UserRecord

type UserRecord struct {
	Hash      string    `json:"hash"`
	CreatedAt time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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