jwt

package
v0.0.0-...-2496799 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder interface {
	// Signed encodes a new JWT token which is signed according to the JWS specification and
	// contains the given claims.
	// The algorithm and key used is left to implementations.
	Signed(claims interface{}) (string, error)

	// Encrypted encodes a new JWT token which is signed and encrypted according to the JWS and
	// JWE specifications, containing the given claims.
	// The algorithm and key used is left to implementations.
	Encrypted(claims interface{}) (string, error)

	// ValidateSigned decodes the given JWT signed token. It validates the signature, checks that
	// it has not expired and parses the claims into the given destination.
	// Tokens are expected with the same algorithm than the Signed method.
	ValidateSigned(token string, dest interface{}) error

	// ValidateEncrypted decodes the given JWT signed and encrypted token. It validates the signature,
	// checks that it has not expired and parses the claims into the given destination.
	// Tokens are expected with the same algorithm than the Encrypted method.
	ValidateEncrypted(token string, dest interface{}) error

	// JWKS obtains the JWK Set definition of the public key used by the encoder to sign tokens,
	// so other services can validate the token signature.
	JWKS() *jose.JSONWebKeySet
}

Encoder is an interface which contains the methods to encode and decode JWT tokens given the token claims. It allows to abstract from the details of cryptography, focusing only in the token contents.

func NewEncoder

func NewEncoder(privateKey *rsa.PrivateKey, keyID string) (Encoder, error)

NewEncoder creates a new Encoder which uses the given RSA private key to sign and encrypt tokens, using the RS512 and RSA_OAEP algorithms.

Jump to

Keyboard shortcuts

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