Documentation
¶
Overview ¶
Package auth places a credential on an upstream call. Operators of the binary use login, client credentials, token exchange, env, invoke, or a command. Library code implements credentials.Provider.
Index ¶
- func Caller(ctx context.Context) string
- func CredentialSecrets(c credentials.Credential) []string
- func DefaultTokenDir() string
- func Fixed(a catalog.Auth, token string) credentials.Provider
- func HasAccessToken(dir, scheme string) bool
- func HasBrowser() bool
- func HasRefreshToken(dir, scheme string) bool
- func Login(ctx context.Context, opt LoginOptions) error
- func OpenBrowser(ctx context.Context, raw string) error
- func OrLocal(id string) string
- func Redact(s string, secrets, queryKeys []string) string
- func RedactURL(raw string, keys []string) string
- func SetToken(dir, scheme, token string) error
- func UserToken(ctx context.Context) string
- func WithCaller(ctx context.Context, id string) context.Context
- func WithEnvProxy(c *http.Client) *http.Client
- func WithForce(ctx context.Context) context.Context
- func WithUserToken(ctx context.Context, token string) context.Context
- type Endpoints
- type LoginOptions
- type Material
- type Options
- type Resolver
- func (r *Resolver) Blockers(a catalog.Auth) []string
- func (r *Resolver) Configured(name string) (Scheme, bool)
- func (r *Resolver) Has(name string) bool
- func (r *Resolver) Material(ctx context.Context, op *catalog.Operation, a catalog.Auth, ...) (Material, error)
- func (r *Resolver) Provider(a catalog.Auth) (credentials.Provider, bool)
- func (r *Resolver) Ready(ctx context.Context, a catalog.Auth) bool
- func (r *Resolver) Refreshable(name string) bool
- func (r *Resolver) SetProvider(name string, src credentials.Provider)
- func (r *Resolver) SuppliesUserHeader(name, header string) bool
- func (r *Resolver) UnsetError(a catalog.Auth) error
- type Scheme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CredentialSecrets ¶
func CredentialSecrets(c credentials.Credential) []string
CredentialSecrets lists header values, query values, and a bearer token without its prefix.
func DefaultTokenDir ¶
func DefaultTokenDir() string
func Fixed ¶
func Fixed(a catalog.Auth, token string) credentials.Provider
Fixed places one already-known secret. It is the provider for a static auth map.
func HasAccessToken ¶
HasAccessToken reports a pasted or minted access token on disk.
func HasBrowser ¶
func HasBrowser() bool
func HasRefreshToken ¶
HasRefreshToken reports a stored refresh token.
func Login ¶
func Login(ctx context.Context, opt LoginOptions) error
Login runs authorization code with PKCE, or device code when there is no browser. It stores the refresh token and does not run during invoke.
func WithCaller ¶
WithCaller records who is calling veto. The value is an identity, not a credential.
func WithEnvProxy ¶
WithEnvProxy returns a client that still honors HTTPS_PROXY when Transport is *http.Transport. A nil Transport uses the default transport, which already reads the proxy environment. Any other RoundTripper is left alone. The caller owns its proxy.
Types ¶
type LoginOptions ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func (*Resolver) Blockers ¶ added in v0.1.5
Blockers lists process-level reasons this scheme cannot run. An invoke token that arrives on the call is not a blocker.
func (*Resolver) Configured ¶
Configured returns the scheme named in config.
func (*Resolver) Material ¶
func (r *Resolver) Material(ctx context.Context, op *catalog.Operation, a catalog.Auth, method, endpoint string, force bool) (Material, error)
Material returns headers and query values for one scheme. force skips a cached token and refreshes once. It does not open a browser.
func (*Resolver) Refreshable ¶
func (*Resolver) SetProvider ¶
func (r *Resolver) SetProvider(name string, src credentials.Provider)
SetProvider registers a library Provider for one scheme name.
func (*Resolver) SuppliesUserHeader ¶ added in v0.1.5
SuppliesUserHeader reports whether a login scheme can place the user token on header.
type Scheme ¶
type Scheme struct {
Name string
Source string
Env string
ClientID string
ClientSecretEnv string
AuthorizationURL string
TokenURL string
Issuer string
DeviceAuthorizationURL string
RedirectURL string
Scopes []string
Audience string
Header string
Command []string
Timeout time.Duration
// AuthToken is the token-response field sent as the app credential. Empty means access_token.
AuthToken string
// UserToken is the token-response field that names the person. Empty means id_token.
UserToken string
// UserHeader is the upstream header that carries the person token.
UserHeader string
// Subject is "invoke" or the name of a login scheme whose stored token is exchanged.
Subject string
// SubjectTokenType is sent on token exchange. Empty means an access token.
SubjectTokenType string
}
Scheme is one configured security scheme. Secrets are not stored here.