credentials

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package credentials provides interface for retrieving local user credentials.

The credentials are retrieved from different sources such as:

  • Gravity local key store.
  • Teleport local key store.
  • Bolt database backend.
  • Preconfigured set of credentials provided on the command line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalKeyStore

func GetLocalKeyStore(dir string) (*users.KeyStore, error)

GetLocalKeyStore opens a key store in the specified directory.

If the directory does not exist, it will be created. If the provided directory is empty, a default key store location is used.

func IsCredentialsNotFoundError

func IsCredentialsNotFoundError(err error) bool

IsCredentialsNotFoundError returns true if the provided error is the credentials not found.

Types

type Config

type Config struct {
	// LocalKeyStoreDir is the local Gravity key store directory (defaults to ~/.gravity).
	LocalKeyStoreDir string
	// TeleportKeyStoreDir is the local Teleport key store directory (defaults to ~/.tsh).
	TeleportKeyStoreDir string
	// Backend is the optional backend for login entries stored in database.
	Backend storage.Backend
	// Credentials is the preconfigured credentials entry.
	Credentials *Credentials
}

Config is the credentials service configuration.

type Credentials

type Credentials struct {
	// URL is the URL of the cluster the credentials are for.
	URL string
	// User is the credentials username.
	User string
	// Entry defines the login entry for username/password authentication.
	Entry users.LoginEntry
	// TLS defines the client configuration for mTLS authentication.
	TLS *tls.Config
}

Credentials defines a set of user credentials.

func FromTokenAndHub

func FromTokenAndHub(token, hub string) *Credentials

FromTokenAndHub creates new credentials from the provided token and address.

type Service

type Service interface {
	// Current returns the currently active user credentials.
	Current() (*Credentials, error)
	// For returns user credentials for the specified cluster.
	For(clusterURL string) (*Credentials, error)
	// UpsertLoginEntry upserts login entry in the local key store.
	//
	// DEPRECATED: This method can removed when authentication via local
	//             Gravity key store is no longer supported.
	UpsertLoginEntry(clusterURL, username, password string) error
}

Service provides access to local user credentials.

func New

func New(config Config) (Service, error)

New creates a new credentials service with the provided config.

Jump to

Keyboard shortcuts

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