interfaces

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthManager

type AuthManager interface {
	// UserExists checks if a user with specified username exists in AuthManager
	UserExists(username string) bool
	// LoginAuth performs a login with the specified username and password
	LoginAuth(username, password string) (fingerPrint, fullname string, err error)
	// LoginAdd creates a new user in AuthManager
	LoginAdd(username, password, fullname, fingerprint string) error
	// ChangePassword changes the password of the specified user
	ChangePassword(username, password string) error
}

AuthManager is an interface to a Authentication Manager Used in Chevron Agent for Authentication StorageBackend

type KeyRingManager

type KeyRingManager interface {
	// GetCachedKeys returns a list of the memory-cached keys
	GetCachedKeys(ctx context.Context) []models.KeyInfo
	// ContainsKey checks if a key with the specified fingerprint exists in Key Ring
	ContainsKey(ctx context.Context, fingerprint string) bool
	// GetKey returns a key with the specified fingerprint if exists. Returns nil if it does not
	GetKey(ctx context.Context, fingerprint string) *openpgp.Entity
	// AddKey adds a key to key ring manager. If nonErasable is true it will be persistent in cache
	AddKey(ctx context.Context, key *openpgp.Entity, nonErasable bool)
	// GetFingerprints returns a list of stored key fingerpints
	GetFingerPrints(ctx context.Context) []string
	// DeleteKey erases the specified key from the key ring
	DeleteKey(ctx context.Context, fingerprint string) error
}

KeyRingManager is an interface to a Key Ring Manager Instance

type PGPManager

type PGPManager interface {
	// LoadKeys loads the keys stored on the PGP Manager key backend
	LoadKeys(ctx context.Context)
	// LoadKeyWithMetadata loads a armored ascii key with the specified json metadata
	LoadKeyWithMetadata(ctx context.Context, armoredKey, metadata string) (int, error)
	// LoadKey loads a armored ascii key
	LoadKey(ctx context.Context, armoredKey string) (int, error)
	// FixFingerPrint fixes and trims the fingerprint to 16 Char Hex
	FixFingerPrint(fingerprint string) string
	// IsKeyLocked returns if the specified key is currently locked inside the PGP Manager
	IsKeyLocked(fingerprint string) bool
	// UnlockKey unlocks the specified key with the specified password
	UnlockKey(ctx context.Context, fingerprint, password string) error
	// GetLoadedPrivateKeys returns the information of each loaded private key
	GetLoadedPrivateKeys(ctx context.Context) []models.KeyInfo
	// GetLoadedKeys returns the information for all keys in PGP Manager
	GetLoadedKeys() []models.KeyInfo
	// SaveKey saves the specified key in PGP Manager Key Backend
	SaveKey(fingerprint, armoredData string, password interface{}) error
	// DeleteKey removes the specified key from the memory and key backend
	DeleteKey(ctx context.Context, fingerprint string) error
	// SignData signs the specified data with a unlocked private key
	SignData(ctx context.Context, fingerprint string, data []byte, hashAlgorithm crypto.Hash) (string, error)
	// GetPublicKeyEntity returns the public key entity
	GetPublicKeyEntity(ctx context.Context, fingerprint string) *openpgp.Entity
	// GetPublicKey returns the public key
	GetPublicKey(ctx context.Context, fingerprint string) *packet.PublicKey
	// GetPublicKeyASCII returns the public key in ASCII Armored format
	GetPublicKeyASCII(ctx context.Context, fingerprint string) (string, error)
	// GetPublicKeyASCII returns the encrypted private key in ASCII Armored format
	GetPrivateKeyASCII(ctx context.Context, fingerprint, password string) (string, error)
	// GetPublicKeyASCII returns the encrypted private key in ASCII Armored format changing it's password
	GetPrivateKeyASCIIReencrypt(ctx context.Context, fingerprint, currentPassword, newPassword string) (string, error)
	// VerifySignatureStringData verifies signature of specified data in string format
	VerifySignatureStringData(ctx context.Context, data string, signature string) (bool, error)
	// VerifySignatureStringData verifies signature of specified data
	VerifySignature(ctx context.Context, data []byte, signature string) (bool, error)
	// GeneratePGPKey generates a new PGP Key with the specified information
	GeneratePGPKey(ctx context.Context, identifier, password string, numBits int) (string, error)
	// Encrypt encrypts data using the specified public key.
	// Filename is a metadata from GPG
	// dataOnly field specifies that it will encrypt as binary content instead ASCII Armored
	Encrypt(ctx context.Context, filename, fingerprint string, data []byte, dataOnly bool) (string, error)
	// Decrypt decrypts data using any available unlocked private key
	Decrypt(ctx context.Context, data string, dataOnly bool) (*models.GPGDecryptedData, error)
	// GetCachedKeys returns all cached public keys in memory
	GetCachedKeys(ctx context.Context) []models.KeyInfo
	// SetKeysBase64Encoded sets if keys should be stored in Base64 Encoded format
	SetKeysBase64Encoded(bool)
	// MinKeyBits returns the minimum key bits allowed for generating PGP Keys
	MinKeyBits() int
	// GenerateTestKey generates a private key for testing
	// Bits: MinKeyBits
	// Password: 1234
	// Identity: *empty string*
	GenerateTestKey() (string, error)
	// GetPrivate returns the private key entity list for a specified private key
	GetPrivate(ctx context.Context, fingerprint string) openpgp.EntityList
	// GetPrivateKeyInfo returns the information of the specified private key
	GetPrivateKeyInfo(ctx context.Context, fingerprint string) *models.KeyInfo
}

PGPManager is a interface for handling PGP Operations

type SecretsManager

type SecretsManager interface {
	// PutKeyPassword stores the password for the specified key fingerprint in the key backend encrypted with the master key
	PutKeyPassword(ctx context.Context, fingerPrint, password string)
	// PutEncryptedPassword stores in memory a master key encrypted password for the specified fingerprint
	PutEncryptedPassword(ctx context.Context, fingerPrint, encryptedPassword string)
	// GetPasswords returns a list of master key encrypted passwords stored in memory
	GetPasswords(ctx context.Context) map[string]string
	// UnlockLocalKeys unlocks the local private keys using memory stored master key encrypted passwords
	UnlockLocalKeys(ctx context.Context, gpg PGPManager)
	// GetMasterKeyFingerPrint returns the fingerprint of the master key
	GetMasterKeyFingerPrint(ctx context.Context) string
}

SecretsManager is a interface for a encrypted secret password manager

type StorageBackend

type StorageBackend interface {
	// Save saves a key to the backend
	Save(key, data string) error
	// SaveWithMetadata saves a key to backend storing some metadata with it
	SaveWithMetadata(key, data, metadata string) error
	// Delete delete a key from backend
	Delete(key string) error
	// Read reads a key from the backend
	Read(key string) (data string, metadata string, err error)
	// List lists the stored keys
	List() ([]string, error)
	// Name returns the name of the KeyBackend
	Name() string
	// Path returns the path of the current KeyBackend
	Path() string
}

StorageBackend is a interface for storing / reading keys

type TokenManager

type TokenManager interface {
	// AddUser adds a user to Token Manager and returns a login token
	AddUser(user UserData) string
	// AddUserWithExpiration adds an user to Token Manager that will expires in `expiration` seconds.
	AddUserWithExpiration(user UserData, expiration int) string
	// Verify verifies if the specified token is valid
	Verify(token string) error
	// GetUserData returns the user data for the specified token
	GetUserData(token string) UserData
	// InvalidateToken invalidates the specified token
	InvalidateToken(token string) error
}

TokenManager is an interface to a Login Token Manager

type UserData

type UserData interface {
	// GetId returns the id
	GetId() string
	// GetUsername returns the username
	GetUsername() string
	// GetFullName returns the user full name
	GetFullName() string
	// GetUserdata returns the raw user data
	GetUserdata() interface{}
	// GetToken returns the user token
	GetToken() string
	// GetCreatedAt returns when the user was created
	GetCreatedAt() time.Time
	// GetFingerPrint returns the user key fingerprint
	GetFingerPrint() string
}

UserData is an interface for user data

Jump to

Keyboard shortcuts

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