auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoToken        = errors.New("no token stored")
	ErrNoEmail        = errors.New("no email stored")
	ErrInvalidBackend = errors.New("invalid keyring backend")
	ErrKeyringTimeout = errors.New("keyring connection timed out")
)

Functions

func ResolveBackend

func ResolveBackend() (string, string, error)

ResolveBackend determines which keyring backend to use.

Types

type Credential

type Credential struct {
	Token     string    `json:"token"`
	Email     string    `json:"email,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

Credential holds stored authentication data.

type KeyringStore

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

KeyringStore implements Store using OS keychain.

func (*KeyringStore) DeleteCredential

func (s *KeyringStore) DeleteCredential() error

DeleteCredential removes all stored credentials.

func (*KeyringStore) DeleteEmail

func (s *KeyringStore) DeleteEmail() error

DeleteEmail removes the stored email.

func (*KeyringStore) DeleteToken

func (s *KeyringStore) DeleteToken() error

DeleteToken removes the stored token.

func (*KeyringStore) GetCredential

func (s *KeyringStore) GetCredential() (Credential, error)

GetCredential retrieves the full credential.

func (*KeyringStore) GetEmail

func (s *KeyringStore) GetEmail() (string, error)

GetEmail retrieves the stored email.

func (*KeyringStore) GetToken

func (s *KeyringStore) GetToken() (string, error)

GetToken retrieves the stored authentication token.

func (*KeyringStore) HasToken

func (s *KeyringStore) HasToken() bool

HasToken checks if a token is stored.

func (*KeyringStore) Keys

func (s *KeyringStore) Keys() ([]string, error)

Keys returns all stored keys.

func (*KeyringStore) SetCredential

func (s *KeyringStore) SetCredential(cred Credential) error

SetCredential stores a full credential (token + email + metadata).

func (*KeyringStore) SetEmail

func (s *KeyringStore) SetEmail(email string) error

SetEmail stores the user's email.

func (*KeyringStore) SetToken

func (s *KeyringStore) SetToken(token string) error

SetToken stores an authentication token.

type Store

type Store interface {
	SetCredential(cred Credential) error
	GetCredential() (Credential, error)
	DeleteCredential() error
	SetToken(token string) error
	GetToken() (string, error)
	DeleteToken() error
	SetEmail(email string) error
	GetEmail() (string, error)
	DeleteEmail() error
	Keys() ([]string, error)
}

Store provides credential storage operations.

func OpenDefault

func OpenDefault() (Store, error)

OpenDefault opens the default keyring store.

Jump to

Keyboard shortcuts

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