Documentation
¶
Overview ¶
Package teamvault provides utilities for accessing and managing TeamVault secrets.
TeamVault is a secret management system, and this package offers Go clients for retrieving passwords, users, URLs, and files from TeamVault instances. It includes various connector implementations for different use cases including remote access, caching, disk fallback, and testing.
The package also provides configuration parsing and generation capabilities to replace TeamVault placeholders in configuration templates with actual secret values.
Index ¶
- Constants
- Variables
- func NormalizePath(path string) (string, error)
- type ApiUrl
- type Config
- type ConfigGenerator
- type ConfigParser
- type Connector
- type CurrentRevision
- type File
- type HtpasswdGenerator
- type Key
- type Keychain
- type KeyringClient
- type Password
- type RealKeyringClient
- type SourceDirectory
- type Staging
- type TargetDirectory
- type TeamvaultConfigPath
- type Url
- type User
Constants ¶
const KeychainServiceName = "teamvault-utils"
KeychainServiceName is the constant service name used for all teamvault-utils Keychain entries. The account key is the TeamVault URL, which keeps multi-vault setups isolated automatically.
Variables ¶
var ErrKeychainNotSupported = errors.New( context.Background(), "keychain storage is supported on macOS only in v1", )
ErrKeychainNotSupported indicates the current platform has no supported credential store backend. Callers may match this with errors.Is to differentiate "no Keychain on this platform" from real Keychain failures.
Functions ¶
func NormalizePath ¶ added in v4.6.1
NormalizePath converts a path to an absolute path, expanding ~ to the home directory.
Types ¶
type ApiUrl ¶
type ApiUrl string
ApiUrl represents a TeamVault API URL.
type Config ¶
type Config struct {
Url Url `json:"url"`
User User `json:"user"`
Password Password `json:"pass"`
CacheEnabled bool `json:"cacheEnabled,omitempty"`
Timeout libtime.Duration `json:"timeout,omitempty"`
}
Config holds the configuration for connecting to a TeamVault instance.
func ParseTeamvaultConfig ¶
ParseTeamvaultConfig parses a TeamVault configuration from JSON content.
type ConfigGenerator ¶
type ConfigGenerator interface {
Generate(
ctx context.Context,
sourceDirectory SourceDirectory,
targetDirectory TargetDirectory,
) error
}
ConfigGenerator generates configuration files by parsing templates and replacing TeamVault placeholders.
func NewConfigGenerator ¶
func NewConfigGenerator(configParser ConfigParser) ConfigGenerator
NewConfigGenerator creates a new ConfigGenerator with the given ConfigParser.
type ConfigParser ¶
ConfigParser parses configuration templates and replaces TeamVault placeholders with actual values.
func NewConfigParser ¶
func NewConfigParser( teamvaultConnector Connector, ) ConfigParser
NewConfigParser creates a new ConfigParser with the given TeamVault Connector.
type Connector ¶
type Connector interface {
Password(ctx context.Context, key Key) (Password, error)
User(ctx context.Context, key Key) (User, error)
Url(ctx context.Context, key Key) (Url, error)
File(ctx context.Context, key Key) (File, error)
Search(ctx context.Context, name string) ([]Key, error)
}
Connector provides access to TeamVault secrets including passwords, users, URLs, and files.
func NewCacheConnector ¶
NewCacheConnector creates a new Connector that caches responses from the underlying connector.
func NewDiskFallbackConnector ¶
NewDiskFallbackConnector creates a new Connector that uses disk cache as fallback when the underlying connector fails.
func NewDummyConnector ¶
func NewDummyConnector() Connector
NewDummyConnector creates a new Connector that returns deterministic dummy values for testing.
func NewRemoteConnector ¶
func NewRemoteConnector( httpClient *http.Client, url Url, user User, pass Password, currentDateTime time.CurrentDateTime, ) Connector
NewRemoteConnector creates a new Connector that connects to a remote TeamVault instance.
type CurrentRevision ¶
type CurrentRevision string
CurrentRevision represents the current revision identifier of a TeamVault secret.
func (CurrentRevision) String ¶
func (t CurrentRevision) String() string
String returns the string representation of the CurrentRevision.
type File ¶
type File string
File represents a base64-encoded file stored in TeamVault.
type HtpasswdGenerator ¶
HtpasswdGenerator generates htpasswd formatted credentials from TeamVault secrets.
func NewHtpasswdGenerator ¶
func NewHtpasswdGenerator(connector Connector) HtpasswdGenerator
NewHtpasswdGenerator creates a new HtpasswdGenerator with the given Connector.
type Key ¶
type Key string
Key represents a TeamVault secret identifier.
type Keychain ¶ added in v4.9.0
type Keychain interface {
// ReadPassword returns the password stored for the given TeamVault URL,
// or ("", nil) if no entry exists. A non-nil error indicates a real
// failure (Keychain locked, security binary error, etc.) — callers
// should surface this to the user, not fall through silently.
ReadPassword(ctx context.Context, url Url) (Password, error)
// WritePassword stores or overwrites the password for the given URL.
// On non-darwin platforms it returns ErrKeychainNotSupported.
WritePassword(ctx context.Context, url Url, password Password) error
}
Keychain reads and writes TeamVault passwords from the OS credential store. On macOS it backs onto the login Keychain via the `security(1)` binary. On other platforms it is a no-op: ReadPassword returns ("", nil); WritePassword returns ErrKeychainNotSupported.
func NewKeychain ¶ added in v4.9.0
func NewKeychain() Keychain
NewKeychain returns a Keychain backed by the OS credential store. On macOS uses Keychain, on Linux uses Secret Service, on Windows uses Credential Manager. On platforms without a supported backend, ReadPassword returns ("", nil) for missing entries and Read/WritePassword return ErrKeychainNotSupported for no-backend errors.
func NewKeychainWithClient ¶ added in v4.13.0
func NewKeychainWithClient(client KeyringClient) Keychain
NewKeychainWithClient returns a Keychain using the given KeyringClient. Useful for tests that need to inject a fake credential store.
type KeyringClient ¶ added in v4.13.0
type KeyringClient interface {
Get(service, user string) (string, error)
Set(service, user, password string) error
}
KeyringClient is the package-private seam over zalando/go-keyring used by darwinKeychain. It exists so unit tests can drive WritePassword/ReadPassword without touching the real macOS Keychain. NewKeychain wires up the real implementation; tests construct darwinKeychain with a Counterfeiter fake.
type Password ¶
type Password string
Password represents a TeamVault password.
func (*Password) UnmarshalJSON ¶ added in v4.7.5
UnmarshalJSON implements json.Unmarshaler to handle both string and number types.
type RealKeyringClient ¶ added in v4.13.0
type RealKeyringClient struct{}
func (RealKeyringClient) Get ¶ added in v4.13.0
func (RealKeyringClient) Get(service, user string) (string, error)
func (RealKeyringClient) Set ¶ added in v4.13.0
func (RealKeyringClient) Set(service, user, password string) error
type SourceDirectory ¶
type SourceDirectory string
SourceDirectory represents the source directory path for configuration generation.
func (SourceDirectory) String ¶
func (s SourceDirectory) String() string
String returns the string representation of the SourceDirectory.
type Staging ¶
type Staging bool
Staging indicates whether the TeamVault instance is a staging environment.
type TargetDirectory ¶
type TargetDirectory string
TargetDirectory represents the target directory path for configuration generation.
func (TargetDirectory) String ¶
func (t TargetDirectory) String() string
String returns the string representation of the TargetDirectory.
type TeamvaultConfigPath ¶
type TeamvaultConfigPath string
TeamvaultConfigPath represents a path to a TeamVault configuration file.
func (TeamvaultConfigPath) Exists ¶
func (t TeamvaultConfigPath) Exists() bool
Exists checks if the TeamvaultConfigPath points to an existing non-empty file.
func (TeamvaultConfigPath) NormalizePath ¶
func (t TeamvaultConfigPath) NormalizePath() (TeamvaultConfigPath, error)
NormalizePath converts the TeamvaultConfigPath to an absolute path.
func (TeamvaultConfigPath) Parse ¶
func (t TeamvaultConfigPath) Parse() (*Config, error)
Parse reads and parses the TeamVault configuration from the file.
func (TeamvaultConfigPath) String ¶
func (t TeamvaultConfigPath) String() string
String returns the string representation of the TeamvaultConfigPath.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
teamvault-config-dir-generator
command
|
|
|
teamvault-config-parser
command
|
|
|
teamvault-file
command
|
|
|
teamvault-login
command
|
|
|
teamvault-password
command
|
|
|
teamvault-url
command
|
|
|
teamvault-username
command
|
|
|
Package factory provides factory functions for creating TeamVault connectors and HTTP clients.
|
Package factory provides factory functions for creating TeamVault connectors and HTTP clients. |
|
Code generated by counterfeiter.
|
Code generated by counterfeiter. |