Documentation
¶
Overview ¶
Package apitokens provides types and functions for managing API tokens and is built on top of the cmdutil/keys package and its InmemoryKeyStore.
Index ¶
- func ClearToken(token []byte)
- func ContextWithKey(ctx context.Context, ki keys.Info) context.Context
- func ContextWithOAuth(ctx context.Context, id, user string, source oauth2.TokenSource) context.Context
- func KeyFromContext(ctx context.Context, id string) (keys.Info, bool)
- func NewErrNotFound(keyID, service string) error
- func OAuthFromContext(ctx context.Context, id string) (oauth2.TokenSource, error)
- func TokenFromContext(ctx context.Context, id string) (*keys.Token, bool)
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearToken ¶
func ClearToken(token []byte)
ClearToken overwrites the contents of the provided token byte slice with zeros.
func ContextWithKey ¶
ContextWithKey returns a new context that contains the provided named key.Info in addition to any existing keys. It wraps keys.ContextWithKey.
func ContextWithOAuth ¶
func ContextWithOAuth(ctx context.Context, id, user string, source oauth2.TokenSource) context.Context
ContextWithOauth returns a new context that contains the provided named oauth2.TokenSource in addition to any existing TokenSources.
func KeyFromContext ¶
KeyFromContext retrieves the key.Info for the specified id from the context. It wraps keys.KeyInfoFromContextForID.
func NewErrNotFound ¶
NewErrNotFound creates a new Error indicating that the specified token was not found. Errors.Is(err, fs.ErrNotExist) can be used to check for this condition.
func OAuthFromContext ¶
OAuthFromContext returns the TokenSource for the specified name, if any, that are stored in the context.