jwt

package
v0.0.0-...-5f0f127 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(tokenStr string, options DecodeOptions) (*identity.DockerIdentity, error)

Decode decodes the given JWT string, returning the decoded identity.DockerIdentity

func Encode

func Encode(identity identity.DockerIdentity, options EncodeOptions) (string, error)

Encode creates a JWT string for the given identity.DockerIdentity.

func FromContext

func FromContext(ctx context.Context) (string, bool)

FromContext returns the token value stored in ctx, if any.

func IsExpired

func IsExpired(tokenStr string, options DecodeOptions) (bool, error)

IsExpired returns true if the token has expired, false otherwise

func NewContext

func NewContext(ctx context.Context, token string) context.Context

NewContext returns a new Context that carries value token.

Types

type DecodeOptions

type DecodeOptions struct {
	CertificateChain *x509.CertPool
}

DecodeOptions holds JWT decoding options

type EncodeOptions

type EncodeOptions struct {
	// The token expiration time, represented as a UNIX timestamp
	Expiration int64

	// The private key with which to sign the token
	SigningKey []byte

	// The x509 certificate associated with the signing key
	Certificate []byte

	// Identifier for the JWT. If this is empty, a random UUID will be generated.
	Jti string

	// Whether or not to include legacy claims that the gateways are still using to validate a JWT.
	IncludeLegacyClaims bool
}

EncodeOptions holds JWT encoding options

type ValidationError

type ValidationError struct {
	VError *jwt.ValidationError
}

ValidationError interrogates the jwt.ValidationError, returning a more detailed error message.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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