apitokens

package
v0.0.0-...-771b66a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 9

README

Package cloudeng.io/webapi/operations/apitokens

import cloudeng.io/webapi/operations/apitokens

Package apitokens provides types and functions for managing API tokens and is built on top of the cmdutil/keys package and its InmemoryKeyStore.

Functions

Func ClearToken
func ClearToken(token []byte)

ClearToken overwrites the contents of the provided token byte slice with zeros.

Func ContextWithKey
func ContextWithKey(ctx context.Context, ki keys.Info) context.Context

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
func KeyFromContext(ctx context.Context, id string) (keys.Info, bool)

KeyFromContext retrieves the key.Info for the specified id from the context. It wraps keys.KeyInfoFromContextForID.

Func NewErrNotFound
func NewErrNotFound(keyID, service string) error

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
func OAuthFromContext(ctx context.Context, id string) (oauth2.TokenSource, error)

OAuthFromContext returns the TokenSource for the specified name, if any, that are stored in the context.

Func TokenFromContext
func TokenFromContext(ctx context.Context, id string) (*keys.Token, bool)

TokenFromContext retrieves the token for the specified id from the context. It returns the token as a *keys.Token and a boolean indicating whether the token was found.

Types

Type Error
type Error struct {
	KeyID   string
	Service string
	Err     error
}

Error represents an error related to API tokens.

Methods
func (e Error) Error() string

Error implements the error interface.

func (e Error) Unwrap() error

Unwrap supports error wrapping by returning the underlying error.

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

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

func ContextWithKey(ctx context.Context, ki keys.Info) context.Context

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

func KeyFromContext(ctx context.Context, id string) (keys.Info, bool)

KeyFromContext retrieves the key.Info for the specified id from the context. It wraps keys.KeyInfoFromContextForID.

func NewErrNotFound

func NewErrNotFound(keyID, service string) error

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

func OAuthFromContext(ctx context.Context, id string) (oauth2.TokenSource, error)

OAuthFromContext returns the TokenSource for the specified name, if any, that are stored in the context.

func TokenFromContext

func TokenFromContext(ctx context.Context, id string) (*keys.Token, bool)

TokenFromContext retrieves the token for the specified id from the context. It returns the token as a *keys.Token and a boolean indicating whether the token was found.

Types

type Error

type Error struct {
	KeyID   string
	Service string
	Err     error
}

Error represents an error related to API tokens.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap supports error wrapping by returning the underlying error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL