auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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