credentials

package
v0.99.0-sumo-0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCollectorCredentialsDirectory = ".sumologic-otel-collector/"
)

Variables

This section is empty.

Functions

func GetDefaultCollectorCredentialsDirectory

func GetDefaultCollectorCredentialsDirectory() (string, error)

func HashKeyToEncryptionKey

func HashKeyToEncryptionKey(key string) ([]byte, error)

HashKeyToEncryptionKey creates an encryption key using a default hasher. It returns the created key and an error.

func HashKeyToEncryptionKeyWith

func HashKeyToEncryptionKeyWith(hasher Hasher, key string) ([]byte, error)

HashKeyToEncryptionKeyWith creates a 32 bytes long key from the provided key using the provided hasher.

func HashKeyToFilename

func HashKeyToFilename(key string) (string, error)

HashKeyToFilename creates a filename using the default hasher and provided key as input. It returns this filename and an error.

func HashKeyToFilenameWith

func HashKeyToFilenameWith(hasher Hasher, key string) (string, error)

HashKeyToFilenameWith creates a filename using the provided key as input and using the provided hasher.

Types

type CollectorCredentials

type CollectorCredentials struct {
	// CollectorName indicates what name was set in the configuration when
	// registration has been made.
	CollectorName string                          `json:"collectorName"`
	Credentials   api.OpenRegisterResponsePayload `json:"collectorCredentials"`
	// ApiBaseUrl saves the destination API base URL which was used for registration.
	// This is used for instance when the API redirects the collector to a different
	// deployment due to the fact that the installation token being used for registration
	// belongs to a different deployment.
	// In order to make collector registration work, we save the destination
	// API base URL so that when the collector starts up again it can use this
	// API base URL for communication with the backend.
	ApiBaseUrl string `json:"apiBaseUrl"`
}

CollectorCredentials are used for storing the credentials received during collector registration.

type Hasher

type Hasher interface {
	Write(p []byte) (n int, err error)
	Sum(b []byte) []byte
}

type LocalFsStore

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

LocalFsStore implements Store interface and can be used to store and retrieve collector credentials from local file system.

Files are stored locally in collectorCredentialsDirectory.

func (LocalFsStore) Check

func (cr LocalFsStore) Check(key string) bool

Check checks if collector credentials can be found under a name being a hash of provided key inside collectorCredentialsDirectory.

func (LocalFsStore) Delete

func (cr LocalFsStore) Delete(key string) error

func (LocalFsStore) Get

Get retrieves collector credentials stored in local file system and then decrypts it using a hash of provided key.

func (LocalFsStore) Store

func (cr LocalFsStore) Store(key string, creds CollectorCredentials) error

Store stores collector credentials in a file in directory as specified in CollectorCredentialsDirectory. The credentials are encrypted using the provided key.

func (LocalFsStore) Validate

func (cr LocalFsStore) Validate() error

Validate checks if the store is operating correctly This mostly means file permissions and the like

type LocalFsStoreOpt

type LocalFsStoreOpt func(*LocalFsStore)

func WithCredentialsDirectory

func WithCredentialsDirectory(dir string) LocalFsStoreOpt

func WithLogger

func WithLogger(l *zap.Logger) LocalFsStoreOpt

type Store

type Store interface {
	// Check checks if collector credentials exist under the specified key.
	Check(key string) bool

	// Get returns the collector credentials stored under a specified key.
	Get(key string) (CollectorCredentials, error)

	// Store stores the provided collector credentials stored under a specified key.
	Store(key string, creds CollectorCredentials) error

	// Delete deletes collector credentials stored under the specified key.
	Delete(key string) error

	// Validate checks if the store is operating correctly
	Validate() error
}

Store is an interface to get collector authentication data

func NewLocalFsStore

func NewLocalFsStore(opts ...LocalFsStoreOpt) (Store, error)

Jump to

Keyboard shortcuts

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