auth

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Token       string `json:"token"`
	AccountID   string `json:"account_id,omitempty"`
	UserEmail   string `json:"user_email,omitempty"`
	DAVUsername string `json:"dav_username,omitempty"` // For CalDAV/WebDAV Basic Auth
	DAVPassword string `json:"dav_password,omitempty"` // Fastmail App Password
}

Credentials holds API token, DAV credentials, and metadata.

type Manager

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

Manager provides authentication services.

func NewManager

func NewManager(cfg *config.Config) *Manager

NewManager creates a new auth Manager.

func NewManagerWithStore

func NewManagerWithStore(cfg *config.Config, store *Store) *Manager

NewManagerWithStore creates a Manager with a specific store (for testing).

func (*Manager) AddDAV

func (m *Manager) AddDAV(password string) error

AddDAV stores an App Password for CalDAV/WebDAV. Username is automatically taken from the stored UserEmail.

func (*Manager) Credentials

func (m *Manager) Credentials() (*Credentials, error)

Credentials returns the stored credentials (for status display).

func (*Manager) DAVCredentials

func (m *Manager) DAVCredentials() (username, password string, err error)

DAVCredentials returns the username and password for CalDAV/WebDAV Basic Auth. Priority: env FASTMAIL_DAV_PASSWORD > stored credentials.

func (*Manager) DAVUsername

func (m *Manager) DAVUsername() (string, error)

DAVUsername returns the username that would be used for DAV auth. Used to validate credentials before persisting them.

func (*Manager) HasDAV

func (m *Manager) HasDAV() bool

HasDAV returns true if CalDAV/WebDAV credentials are fully usable (both username and password are available).

func (*Manager) IsAuthenticated

func (m *Manager) IsAuthenticated() bool

IsAuthenticated returns true if a token is available.

func (*Manager) Login

func (m *Manager) Login(token string) error

Login stores a token after basic validation. Preserves existing DAV credentials if present.

func (*Manager) LoginWithMetadata

func (m *Manager) LoginWithMetadata(token, accountID, email string) error

LoginWithMetadata stores a token along with account metadata. Preserves existing DAV credentials if present.

func (*Manager) Logout

func (m *Manager) Logout() error

Logout clears stored credentials.

func (*Manager) Token

func (m *Manager) Token() (string, error)

Token returns the API token. Priority: env > keyring/file.

func (*Manager) UsingKeyring

func (m *Manager) UsingKeyring() bool

UsingKeyring returns true if credentials are stored in the system keyring.

type Store

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

Store handles credential storage with keyring + file fallback.

func NewStore

func NewStore(fallbackDir string) *Store

NewStore creates a credential store.

func (*Store) Delete

func (s *Store) Delete() error

Delete removes credentials.

func (*Store) Load

func (s *Store) Load() (*Credentials, error)

Load retrieves credentials.

func (*Store) Save

func (s *Store) Save(creds *Credentials) error

Save stores credentials.

func (*Store) UsingKeyring

func (s *Store) UsingKeyring() bool

UsingKeyring returns true if the store uses the system keyring.

Jump to

Keyboard shortcuts

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