credentials

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package credentials implements our struct stored in keychain. Store struct is kind of like a database client. Credentials struct is kind of like one record from the database.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound           = errors.New("Credentials not found")
	ErrLocked             = errors.New("Credentials are locked")
	ErrDecryptionFailed   = errors.New("Decryption of credentials failed")
	ErrEncryptionFailed   = errors.New("Encryption of credentials failed")
	ErrUnauthorized       = errors.New("Bridge credentials checking failed")
	ErrAlreadyExists      = errors.New("Credential already exists")
	ErrCantRemoveMainSlot = errors.New("Cannot remove the main key slot")
)

Functions

func Decrypt added in v0.3.0

func Decrypt(msg []byte, key [32]byte) ([]byte, error)

func Encrypt added in v0.3.0

func Encrypt(msg []byte, key [32]byte) ([]byte, error)

func GenerateKey added in v0.3.0

func GenerateKey(size uint) []byte

Types

type Credentials

type Credentials struct {
	UserID       string
	Name         string
	Emails       []string
	Secret       Secret `json:"-"`
	SealedSecret []byte
	SealedKeys   map[string][]byte
	Key          [32]byte `json:"-"`
}

func (*Credentials) Decrypt added in v0.3.0

func (s *Credentials) Decrypt() error

func (*Credentials) Encrypt added in v0.3.0

func (s *Credentials) Encrypt() error

func (*Credentials) IsConnected

func (s *Credentials) IsConnected() bool

func (*Credentials) Locked added in v0.3.0

func (s *Credentials) Locked() bool

func (*Credentials) SealKey added in v0.3.0

func (s *Credentials) SealKey(slot string, key [32]byte) error

func (*Credentials) SplitAPIToken

func (s *Credentials) SplitAPIToken() (string, string, error)

func (*Credentials) Unlock added in v0.3.0

func (s *Credentials) Unlock(slot, password string) error

type Secret added in v0.3.0

type Secret struct {
	APIToken        string
	MailboxPassword []byte
}

type Store

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

Store is an encrypted credentials store.

func NewStore

func NewStore(filePath string) (*Store, error)

NewStore creates a new encrypted credentials store.

func (*Store) Add

func (s *Store) Add(userID, userName, uid, ref string, mailboxPassword []byte, emails []string) (*Credentials, []byte, error)

func (*Store) AddKeySlot added in v0.3.0

func (s *Store) AddKeySlot(userID, slot, mainKey string) (string, error)

func (*Store) Delete

func (s *Store) Delete(userID string) (err error)

Delete removes credentials from the store.

func (*Store) Get

func (s *Store) Get(userID string) (creds *Credentials, err error)

func (*Store) List

func (s *Store) List() ([]string, error)

List returns a list of usernames that have credentials stored.

func (*Store) ListKeySlots added in v0.3.0

func (s *Store) ListKeySlots(userID string) ([]string, error)

func (*Store) Logout

func (s *Store) Logout(userID string) (*Credentials, error)

func (*Store) RemoveKeySlot added in v0.3.0

func (s *Store) RemoveKeySlot(userID, slot string) error

func (*Store) UpdateEmails

func (s *Store) UpdateEmails(userID string, emails []string) (*Credentials, error)

func (*Store) UpdatePassword

func (s *Store) UpdatePassword(userID string, password []byte) (*Credentials, error)

func (*Store) UpdateToken

func (s *Store) UpdateToken(userID, uid, ref string) (*Credentials, error)

Jump to

Keyboard shortcuts

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