jwt

package
v0.0.0-...-888d963 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be a PEM encoded PKCS1 or PKCS8 key")
	ErrNotRSAPrivateKey    = errors.New("Key is not a valid RSA private key")
	ErrNotRSAPublicKey     = errors.New("Key is not a valid RSA public key")
)

Functions

func Encode

func Encode(payload TokenPayload) string

func LoadRSAPrivateKeyFromDisk

func LoadRSAPrivateKeyFromDisk(location string) *rsa.PrivateKey

func LoadRSAPublicKeyFromDisk

func LoadRSAPublicKeyFromDisk(location string) *rsa.PublicKey

func ParseRSAPrivateKeyFromPEM

func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)

func ParseRSAPublicKeyFromPEM

func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)

func Sign

func Sign(data string, key *rsa.PrivateKey) (string, error)

func Verify

func Verify(data string, signature string, key *rsa.PublicKey) bool

Types

type JWT

type JWT struct {
	Raw       string
	Header    TokenHeader
	Payload   TokenPayload
	Signature string
	Valid     bool
}

func Decode

func Decode(jwt string) (JWT, error)

type TokenHeader

type TokenHeader struct {
	Algorithm string `json:"alg"`
	Typ       string `json:"typ"`
}

type TokenPayload

type TokenPayload struct {
	Issuer         string `json:"iss"`
	Subject        string `json:"sub"`
	Audience       string `json:"aud"`
	IssuedAt       int64  `json:"iat"`
	ExpirationTime int64  `json:"exp"`
}

Jump to

Keyboard shortcuts

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