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 AzureLoginHint(resource string) string
- func AzureSecret(ctx context.Context, path string) (string, error)
- func AzureTenant(token string) string
- func AzureToken(ctx context.Context, resource 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 KeyVaultResource(path string) string
- 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 ErrAzureLogin = errors.New("no Azure login")
ErrAzureLogin is wrapped by errors that an Azure login fixes.
var ErrGCPLogin = errors.New("google cloud credentials required")
ErrGCPLogin is wrapped by errors that credentials fix.
var ErrGCPNoCredentials = errors.New("none found")
ErrGCPNoCredentials is wrapped, with ErrGCPLogin, when no Google credentials were found at all (not one that failed).
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 AzureLoginHint ¶ added in v0.9.0
AzureLoginHint says how to give komando an Azure login for resource. The Azure CLI saves a resource manager token at `az login` and renews it with each az command; a token for another resource only when asked.
func AzureSecret ¶ added in v0.9.0
AzureSecret reads a Key Vault secret. path is VAULT/NAME or VAULT/NAME/VERSION; without a version it is the current one.
func AzureTenant ¶ added in v0.9.0
AzureTenant is the tenant an Azure AD access token was given in (its tid claim), or "". The token is not checked: the service it goes to does.
func AzureToken ¶ added in v0.9.0
AzureToken is an access token for resource (an Azure AD resource such as https://vault.azure.net), from the first login that is there:
- a service principal: AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET;
- a workload identity (AKS): AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_FEDERATED_TOKEN_FILE;
- a token for resource that the Azure CLI saved and that is still good (az refreshes it; komando cannot without the CLI's own app id);
- the managed identity of this Azure machine (AZURE_CLIENT_ID picks a user-assigned one).
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 and `gcloud auth print-access-token` a registry login.
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 KeyVaultResource ¶ added in v0.9.0
KeyVaultResource is the Azure AD resource for the vault of an azure-kv: path (VAULT/NAME), which is the one an Azure CLI token must be for: https://vault.azure.cn for shop.vault.azure.cn. It is the public cloud's for a vault name without a host, or one that is not valid.
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.