tokens

package
v4.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPrivateKeySpecified occurs when the private key was not set
	// and there was an attempt to create a token
	ErrNoPrivateKeySpecified = errors.New("private key is nil")
)

Functions

This section is empty.

Types

type Creator

type Creator interface {
	// Create creates a signed token that can be used for interservice communication.
	Create(reference string, opts Options) (string, error)
}

Creator creates all kinds of signed tokens for the background tasks

func NewCreator

func NewCreator(issuer string, privateKey *rsa.PrivateKey, lifetime time.Duration) Creator

NewCreator creates a new token creator for tasks

type CreatorMock

type CreatorMock struct {
	Err   error
	Token string
	Opts  Options
}

CreatorMock is a utility function to simplify writing tests that use the Creator

func (*CreatorMock) Create

func (m *CreatorMock) Create(reference string, opts Options) (string, error)

Create implements tokens.Creator

type Options

type Options struct {
	// Audience is a name of the service that receives the request. Other
	// services should not validate tokens intended for other services.
	Audience string
	// ProjectID is the UUID string for a project that the token should be
	// considered a member and an admin of. This value is deprecated, but
	// exists for backwards compatibility during the transition to `azp`.
	ProjectID string
	// ID is the UUID string to identify this token.
	// It will be a random UUID if not specified.
	ID string
	// UserID is the UUID string to identify the user that the token is
	// intended for. It will be the null UUID when not specified
	UserID string
}

Options control the value or the generation of the claims in the resulting token. All values are optional and the empty value will be ignored.

Jump to

Keyboard shortcuts

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