Documentation
¶
Overview ¶
Package cloud holds komando's own clients for cloud and secret-manager APIs, so no vendor CLI (aws, gcloud, vault) has to be installed (docs/design/built-in.md). Logins stay with the person: komando reads the credentials they already have and never stores them.
Index ¶
- Variables
- func AWSConfig(ctx context.Context, profile, region string) (aws.Config, error)
- func AWSCredentials(ctx context.Context, profile string) (aws.Credentials, error)
- func AWSProfileAccess(ctx context.Context, profile, configFile, credsFile string) (aws.Credentials, string, string, error)
- func AWSProfileMissing(err error) bool
- func AWSSSOLogin(ctx context.Context, profile string, show func(url, code string)) (string, error)
- func AWSSecret(ctx context.Context, id string) (string, error)
- func Bitwarden(ctx context.Context, ref string) (string, error)
- func BitwardenDecrypt(s string, key []byte) ([]byte, error)
- func BitwardenEncrypt(plain, key []byte) (string, error)
- func BitwardenMasterKey(password, email string, kdf, iterations, memoryMiB, parallelism int) ([]byte, error)
- func BitwardenPasswordHash(master []byte, password string) string
- func BitwardenStretch(master []byte) []byte
- func ECRToken(ctx context.Context, profile, region string) (string, error)
- func EKSToken(ctx context.Context, profile, region, cluster, roleARN string) (string, error)
- func GCPAccessToken(ctx context.Context) (string, error)
- func GCPSecret(ctx context.Context, name, project string) (string, error)
- func KeePass(ref string) (string, error)
- func OnePassword(ctx context.Context, ref string) (string, error)
- func SSMDial(ctx context.Context, profile, region, target, port string) (net.Conn, error)
- func VaultKV(ctx context.Context, path, field string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrAWSLogin = errors.New("AWS login required")
ErrAWSLogin is wrapped by errors that a person fixes by logging in again (an expired or missing SSO session).
var ErrGCPLogin = errors.New("google cloud credentials required")
ErrGCPLogin is wrapped by errors that credentials fix.
var ErrNoConnect = errors.New("1Password Connect is not set up (OP_CONNECT_HOST and OP_CONNECT_TOKEN)")
ErrNoConnect: op:// needs a 1Password Connect server (OP_CONNECT_HOST).
Functions ¶
func AWSConfig ¶
AWSConfig is the SDK configuration for a profile: "" or "default" is the usual chain (environment, ~/.aws/config and credentials, SSO, roles, instance metadata). region overrides the profile's region when set.
func AWSCredentials ¶
AWSCredentials are the profile's current keys.
func AWSProfileAccess ¶ added in v0.3.0
func AWSProfileAccess(ctx context.Context, profile, configFile, credsFile string) (aws.Credentials, string, string, error)
AWSProfileAccess is what a profile in the given config and credentials files gives: its current keys, region and custom endpoint ("" for AWS).
func AWSProfileMissing ¶
AWSProfileMissing reports whether err says the profile is not in ~/.aws/config or ~/.aws/credentials.
func AWSSSOLogin ¶
AWSSSOLogin logs a person in to the IAM Identity Center (SSO) of a profile, the way `aws sso login` does: the device-code flow. show gets the page and the code to confirm there. The token is written to the same cache file the aws CLI uses (~/.aws/sso/cache), so the SDK, the aws CLI and komando share the login.
func Bitwarden ¶
Bitwarden reads bw://ITEM/FIELD. FIELD is password, username, notes, uri, totp, or the name of a custom field. ITEM is the item's name or id.
func BitwardenDecrypt ¶
BitwardenDecrypt opens a type 2 cipher string "2.IV|DATA|MAC" (AES-256-CBC with HMAC-SHA256, encrypt-then-MAC). key is 64 bytes.
func BitwardenEncrypt ¶
BitwardenEncrypt makes a type 2 cipher string (used by tests and the e2e seeding; komando itself only reads).
func BitwardenMasterKey ¶
func BitwardenMasterKey(password, email string, kdf, iterations, memoryMiB, parallelism int) ([]byte, error)
BitwardenMasterKey derives the 32-byte master key: kdf 0 is PBKDF2-SHA256 (salt: the e-mail in lower case), kdf 1 Argon2id (salt: its SHA-256; memory in MiB).
func BitwardenPasswordHash ¶
BitwardenPasswordHash is what the server checks at login: one more PBKDF2 round of the master key with the password as salt.
func BitwardenStretch ¶
BitwardenStretch expands the master key into an encryption and a MAC key (64 bytes: enc then mac), with HKDF-Expand.
func EKSToken ¶
EKSToken is a bearer token for an Amazon EKS cluster, made the way `aws eks get-token` and aws-iam-authenticator make it: a presigned STS GetCallerIdentity URL naming the cluster, valid for 15 minutes. roleARN, when set, is assumed first.
func GCPAccessToken ¶
GCPAccessToken is an OAuth access token from the application-default credentials, as gke-gcloud-auth-plugin gives GKE.
func GCPSecret ¶
GCPSecret reads the latest version of a Secret Manager secret. name is a secret id (project from project, the credentials or the gcloud config), or a full projects/P/secrets/S[/versions/V] name.
func KeePass ¶
KeePass reads one field of an entry in a KeePass or KeePassXC file (KDBX 3.1 and 4). ref is FILE#GROUP/.../ENTRY[#FIELD]; the field is the password unless named (UserName, URL, Notes, or a custom one). The file is opened with KOMANDO_KDBX_PASSWORD and/or the key file KOMANDO_KDBX_KEYFILE.
func OnePassword ¶
OnePassword reads op://VAULT/ITEM[/SECTION]/FIELD from a 1Password Connect server, through its documented REST API: OP_CONNECT_HOST is the server, OP_CONNECT_TOKEN its access token. Vaults and items are matched by name or id, fields by label or id (and section when given).
func VaultKV ¶
VaultKV reads one field of a KV secret from HashiCorp Vault or OpenBao, the way `vault kv get -field=FIELD PATH` does: PATH starts with the mount ("secret/shop/db"), KV version 1 or 2 is found out from the mount. The address and token come from the same places the CLI uses: VAULT_ADDR, VAULT_TOKEN or ~/.vault-token, VAULT_NAMESPACE, VAULT_CACERT.
Types ¶
This section is empty.