keys

package
v3.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSourcesResolved represents an error for when no sources could be resolved at all
	ErrNoSourcesResolved = ErrGetKeySource{"no sources could be resolved"}

	// ErrEmptyURL represents an error for when an expected url is an empty string
	ErrEmptyURL = ErrGetKeySource{"url cannot be empty"}

	// ErrEmptyFilePath represents an error for when an expected file path is an empty string
	ErrEmptyFilePath = ErrGetKeySource{"file path cannot be empty"}
)
View Source
var (
	// JWTPublicKeyEnvStringSource represents the source of an RSA public key as a string
	JWTPublicKeyEnvStringSource = StringSource(os.Getenv("JWT_PUBLIC_KEY"))

	// JWTPublicKeyEnvHTTPSource represents the source of an RSA public key at a HTTP GET destination
	JWTPublicKeyEnvHTTPSource = HTTPSource(os.Getenv("JWT_PUBLIC_KEY_URL"))

	// JWTPublicKeyEnvFileSource represents the source of an RSA public key on disk
	JWTPublicKeyEnvFileSource = FileSource(os.Getenv("JWT_PUBLIC_KEY_PATH"))

	// JWTPublicKeyDefaultFileSource represents the source of an RSA public key on disk
	JWTPublicKeyDefaultFileSource = FileSource("/usr/local/var/jwt.pub")

	// JWTPublicKeySources represents a chain of sources for JWT Public Keys
	JWTPublicKeySources = Sources{
		JWTPublicKeyEnvStringSource,
		JWTPublicKeyEnvFileSource,
		JWTPublicKeyEnvHTTPSource,
		JWTPublicKeyDefaultFileSource,
	}
)

Functions

This section is empty.

Types

type ErrGetKeySource

type ErrGetKeySource struct {
	// contains filtered or unexported fields
}

ErrGetKeySource represents an error when failing to get the source

func (ErrGetKeySource) Error

func (e ErrGetKeySource) Error() string

type ErrReadResponse

type ErrReadResponse struct {
	// contains filtered or unexported fields
}

ErrReadResponse represents an error when failing to read the source data

func (ErrReadResponse) Error

func (e ErrReadResponse) Error() string

type FileSource

type FileSource string

FileSource defines a path to a file on disk

func (FileSource) Get

func (source FileSource) Get(ctx context.Context) ([]byte, error)

Get retrieves data from the path to a file on disk

type HTTPSource

type HTTPSource string

HTTPSource defines a source with a URL to resolve over HTTP

func (HTTPSource) Get

func (source HTTPSource) Get(ctx context.Context) ([]byte, error)

Get retrieves data from the URL over HTTP

type RSAPublicKeyBroker

type RSAPublicKeyBroker struct {
	// contains filtered or unexported fields
}

RSAPublicKeyBroker defines the implementation for brokering an RSA public key

func (*RSAPublicKeyBroker) Copy

func (b *RSAPublicKeyBroker) Copy() rsa.PublicKey

Copy returns a shallow copy o the RSA public key

func (*RSAPublicKeyBroker) Renew

func (b *RSAPublicKeyBroker) Renew()

Renew will inform the broker to force renewal of the key

type RSAPublicKeyBrokerMock

type RSAPublicKeyBrokerMock struct {
	// contains filtered or unexported fields
}

RSAPublicKeyBrokerMock defines the implementation for brokering an RSA public key during testing

func (*RSAPublicKeyBrokerMock) Copy

Copy returns a shallow copy o the RSA public key

func (*RSAPublicKeyBrokerMock) Renew

func (b *RSAPublicKeyBrokerMock) Renew()

Renew is a no-op

type RSAPublicKeyCopier

type RSAPublicKeyCopier interface {
	Copy() rsa.PublicKey
}

RSAPublicKeyCopier represents behaviour for distributing copies of public keys

type RSAPublicKeyCopierRenewer

type RSAPublicKeyCopierRenewer interface {
	RSAPublicKeyCopier
	Renewer
}

RSAPublicKeyCopierRenewer represents the combination of a Copier and Renewer interface

func BrokerRSAPublicKey

func BrokerRSAPublicKey(ctx context.Context, source Source, tick time.Duration) (RSAPublicKeyCopierRenewer, func())

BrokerRSAPublicKey will broker a public key from a source on an interval

func MockRSAPublicKey

func MockRSAPublicKey(key rsa.PublicKey) RSAPublicKeyCopierRenewer

MockRSAPublicKey resolves any source and returns a mocked RSAPublicKeyCopier and Renewer

type Renewer

type Renewer interface {
	Renew()
}

Renewer represents behaviour for marking a broker for renewal

type Source

type Source interface {
	Get(ctx context.Context) ([]byte, error)
}

Source represents one or a chain of sources

type Sources

type Sources []Source

Sources defines a chain of sources

func (Sources) Get

func (sources Sources) Get(ctx context.Context) ([]byte, error)

Get iterates sources and returns the first successfully resolved

type StringSource

type StringSource string

StringSource defines the source as a string

func (StringSource) Get

func (source StringSource) Get(ctx context.Context) ([]byte, error)

Get converts the string to a byte slice

Jump to

Keyboard shortcuts

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