cloud

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 49 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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/code-layout.md). Logins stay with the person: komando reads the credentials they already have and never stores them.

Index

Constants

This section is empty.

Variables

View Source
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).

View Source
var ErrAWSNotSSO = errors.New("the profile does not use SSO")

ErrAWSNotSSO says a profile has no IAM Identity Center (SSO) login: its keys come from ~/.aws/credentials or the environment, so there is nothing to log in to.

View Source
var ErrAzureLogin = errors.New("no Azure login")

ErrAzureLogin is wrapped by errors that an Azure login fixes.

View Source
var ErrGCPLogin = errors.New("google cloud credentials required")

ErrGCPLogin is wrapped by errors that credentials fix.

View Source
var ErrGCPNoCredentials = errors.New("none found")

ErrGCPNoCredentials is wrapped, with ErrGCPLogin, when no Google credentials were found at all (not one that failed).

View Source
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).

View Source
var UnlockEnv = os.Getenv

UnlockEnv reads a variable that unlocks a secret store (KOMANDO_BW_PASSWORD, KOMANDO_KDBX_PASSWORD, OP_CONNECT_TOKEN, VAULT_TOKEN...). komando's vault sets it to also find the values it took out of the environment when it started (vault.TakeUnlockEnv), so the programs komando starts never inherit them.

Functions

func AWSConfig

func AWSConfig(ctx context.Context, profile, region string) (aws.Config, error)

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

func AWSCredentials(ctx context.Context, profile string) (aws.Credentials, error)

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

func AWSProfileMissing(err error) bool

AWSProfileMissing reports whether err says the profile is not in ~/.aws/config or ~/.aws/credentials.

func AWSSSOLogin

func AWSSSOLogin(ctx context.Context, profile string, show func(url, code string)) (string, error)

AWSSSOLogin logs a person in to the IAM Identity Center (SSO) of a profile, the way `aws sso login` does: the device-code flow. A profile that assumes a role from an SSO profile logs in to that one. 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 AWSSecret

func AWSSecret(ctx context.Context, id string) (string, error)

AWSSecret reads a Secrets Manager secret (name or ARN) as text.

func AzureLoginHint added in v0.9.0

func AzureLoginHint(resource string) string

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

func AzureSecret(ctx context.Context, path string) (string, error)

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

func AzureTenant(token string) string

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

func AzureToken(ctx context.Context, resource string) (string, error)

AzureToken is an access token for resource (an Azure AD resource such as https://vault.azure.net), from the first login that is there:

  1. a service principal: AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET;
  2. a workload identity (AKS): AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_FEDERATED_TOKEN_FILE;
  3. 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);
  4. the managed identity of this Azure machine (AZURE_CLIENT_ID picks a user-assigned one).

func Bitwarden

func Bitwarden(ctx context.Context, ref string) (string, error)

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

func BitwardenDecrypt(s string, key []byte) ([]byte, error)

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

func BitwardenEncrypt(plain, key []byte) (string, error)

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

func BitwardenPasswordHash(master []byte, password string) string

BitwardenPasswordHash is what the server checks at login: one more PBKDF2 round of the master key with the password as salt.

func BitwardenStretch

func BitwardenStretch(master []byte) []byte

BitwardenStretch expands the master key into an encryption and a MAC key (64 bytes: enc then mac), with HKDF-Expand.

func ECRToken

func ECRToken(ctx context.Context, profile, region string) (string, error)

ECRToken is a registry password for Amazon ECR (it lasts 12 hours).

func EKSToken

func EKSToken(ctx context.Context, profile, region, cluster, roleARN string) (string, error)

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

func GCPAccessToken(ctx context.Context) (string, error)

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

func GCPSecret(ctx context.Context, name, project string) (string, error)

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

func KeePass(ref string) (string, error)

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

func KeyVaultResource(path string) string

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

func OnePassword(ctx context.Context, ref string) (string, error)

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 SSMDial

func SSMDial(ctx context.Context, profile, region, target, port string) (net.Conn, error)

SSMDial opens an SSH stream to an EC2 instance through Session Manager.

func VaultKV

func VaultKV(ctx context.Context, path, field string) (string, error)

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

type AWSSSO added in v0.13.0

type AWSSSO struct {
	Profile, StartURL, Region string

	// Role is the profile's role_arn, also when there is no SSO behind it
	Role string
	// contains filtered or unexported fields
}

AWSSSO is the SSO login a profile uses: its own, or that of the profile its role is assumed from (role_arn with source_profile). key names the token's cache file.

func AWSProfileSSO added in v0.13.0

func AWSProfileSSO(ctx context.Context, profile string, files ...string) (AWSSSO, error)

AWSProfileSSO is the SSO login behind a profile, or an error wrapping ErrAWSNotSSO when it has none. files, when given, are the config and credentials file to read (import).

Jump to

Keyboard shortcuts

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