Documentation
¶
Overview ¶
Package auth loads OSF credentials from caller-provided sources and redacts secrets from user-visible errors and logs.
Index ¶
Constants ¶
const PasswordEnv = "OSF_PASSWORD"
PasswordEnv is the environment variable that stores the OSF password.
const TokenEnv = "OSF_TOKEN"
TokenEnv is the environment variable that stores the OSF personal access token.
const UsernameEnv = "OSF_USERNAME"
UsernameEnv is the environment variable that stores the OSF username/email.
Variables ¶
This section is empty.
Functions ¶
func RedactError ¶
RedactError returns an error whose message has sensitive values removed.
Types ¶
type Credentials ¶
Credentials contains the selected OSF credential material.
func LoadCredentials ¶
func LoadCredentials(source Source) (Credentials, error)
LoadCredentials selects credentials from the supplied source.
OSF_TOKEN has precedence. OSF_USERNAME and OSF_PASSWORD are used only when no token is present.
func (Credentials) Authenticated ¶
func (c Credentials) Authenticated() bool
Authenticated reports whether the credentials can authenticate OSF requests.
func (Credentials) Secrets ¶
func (c Credentials) Secrets() []string
Secrets returns concrete secret values that should be redacted from output.
type FuncSource ¶
FuncSource adapts a lookup function into a Source.
type MissingCredentialsError ¶
MissingCredentialsError reports that no complete supported credential set was found.
func (MissingCredentialsError) Error ¶
func (e MissingCredentialsError) Error() string
Error implements error.
type MissingTokenError ¶
type MissingTokenError struct {
Env string
}
MissingTokenError reports that no usable token was found.
type Mode ¶
type Mode string
Mode identifies the credential mechanism used for OSF requests.
const ( // ModeAnonymous means no credentials were supplied. ModeAnonymous Mode = "anonymous" // ModeBearerToken means requests should use Authorization: Bearer. ModeBearerToken Mode = "bearer-token" // ModeUsernamePassword means requests should use username/password signing. ModeUsernamePassword Mode = "username-password" )