Documentation
¶
Overview ¶
Package auth finds the OpenArch URL and credentials of a command.
For each value, the first source that has one wins: flags, then environment variables, then a base connection, then a hidden prompt. The base connection is a context chosen with --context or OPENARCH_CONTEXT, else the workspace found with --dir or in the current folder, else the current context. Credentials of the base connection are used only for its own URL, so they are never sent to another server.
Index ¶
Constants ¶
const ( EnvURL = "OPENARCH_URL" EnvUser = "OPENARCH_USER" EnvPassword = "OPENARCH_PASSWORD" EnvInsecure = "OPENARCH_INSECURE" )
Environment variables.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
URL string
User string
Password string
Insecure bool
Sources Sources
// Workspace is the workspace folder, when the URL came from it.
Workspace string
// Context is the name of the context used, if any.
Context string
// DialAddr, when set, is the host:port to connect to instead of the URL host.
// A workspace URL can use a server name that does not resolve on this machine.
DialAddr string
// RootCAPEM is an extra trusted certificate, such as a self-signed workspace certificate.
RootCAPEM []byte
}
Credentials is a resolved connection.
func Resolve ¶
func Resolve(in Input) (Credentials, error)
Resolve finds the URL, user and password.
func (Credentials) Describe ¶
func (c Credentials) Describe() string
Describe says where the credentials came from, for error hints. It never shows the password.
type Input ¶
type Input struct {
URL string
User string
Password string // from --password
PasswordStdin bool
Insecure bool
InsecureSet bool
Stdin io.Reader
Getenv func(string) string
// WorkspaceDir is the folder to look for openarch.yaml in. Empty means no workspace.
WorkspaceDir string
// Prompt asks for a value. Nil when the command cannot prompt.
Prompt func(label string, secret bool) (string, error)
// Context is the --context flag. The OPENARCH_CONTEXT variable is read with Getenv.
Context string
// Contexts is the CLI config. Nil means no contexts.
Contexts *contexts.Config
// Store opens the credential store, for passwords of remote contexts.
Store func() (credstore.Store, error)
// AllowNoPassword returns the credentials even when no password is found.
AllowNoPassword bool
}
Input holds the raw values of a command.