Documentation
¶
Overview ¶
Package auth stores the management token, binds it to one server and resolves the credential for each run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotSignedIn = errors.New("not signed in")
ErrNotSignedIn means no credential is available for the server.
Functions ¶
func CheckTokenShape ¶
CheckTokenShape rejects text that cannot be a management token.
func DisplayName ¶
DisplayName is how cchp names a signed-in identity to people.
func NormalizeServer ¶
NormalizeServer checks a server address and returns its canonical form: scheme, host, optional port and optional path prefix, without a trailing slash. Plain http is allowed only for this machine, so tokens never cross a network unencrypted.
func TokenPrefix ¶
TokenPrefix returns the public part of a management token, cch_auth_live_<prefix>.
Types ¶
type Config ¶
type Config struct {
Current string `json:"current,omitempty"`
Profiles map[string]*Profile `json:"profiles,omitempty"`
}
Config is cchp's config.json.
type Credential ¶
type Credential struct {
Server string
Token string
Source string // env, token-file, keychain or file
Identity *Identity
}
Credential is the token cchp uses for one run.
type Dirs ¶
Dirs locates cchp's files.
func DefaultDirs ¶
DefaultDirs honours CCHP_CONFIG_DIR and CCHP_CACHE_DIR.
type Identity ¶
type Identity struct {
UserID string `json:"user_id,omitempty"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
OrganizationID string `json:"organization_id,omitempty"`
OrganizationName string `json:"organization_name,omitempty"`
OrgRole string `json:"org_role,omitempty"`
TokenKind string `json:"token_kind,omitempty"`
IsPlatformAdmin bool `json:"is_platform_admin"`
}
Identity is what the server said about the token at sign-in.
type Profile ¶
type Profile struct {
Server string `json:"server"`
TokenPrefix string `json:"token_prefix"`
Store string `json:"store"`
Identity Identity `json:"identity"`
SignedInAt time.Time `json:"signed_in_at"`
}
Profile is the non-secret record of a sign-in, kept in config.json.
type Store ¶
Store reads and writes credentials and config.json.
func OpenStore ¶
OpenStore picks the credential backend: the OS keychain when one is reachable, otherwise a mode-600 file. CCHP_CREDENTIAL_STORE=keychain|file chooses explicitly.
func (*Store) Resolve ¶
func (s *Store) Resolve() (*Credential, error)
Resolve finds the credential for this run. Environment variables come first (CCHP_TOKEN or CCHP_TOKEN_FILE, always with CCHP_BASE_URL), then the stored credential of CCHP_BASE_URL or of the current server.