jwt

package
v0.0.0-...-106859a Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectSignature = errors.New("incorrect signature")

Functions

func CheckSignature

func CheckSignature(signedToken string, signingKey string) error

func Decrypt

func Decrypt(encryptedToken string, decryptionKey string) (string, error)

func Encrypt

func Encrypt(signedToken string, encryptionKey string) (string, error)

func Pack

func Pack(token Token, settings PackSettings) (string, error)

func Serialize

func Serialize(token Token) (string, error)

func Sign

func Sign(encodedToken string, signingKey string) (string, error)

Types

type Header struct {
	SignatureAlgorithm string `json:"alg"`
	TokenType          string `json:"typ"`
}

type PackSettings

type PackSettings struct {
	SignatureKey  string
	EncryptionKey string
}

type Timestamp

type Timestamp time.Time

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(serializedTimestamp []byte) (err error)

type Token

type Token struct {
	Issuer         string    `json:"iss"`
	Subject        string    `json:"sub"`
	Audience       string    `json:"aud"`
	ExpirationTime Timestamp `json:"exp"`
}

func Deserialize

func Deserialize(serializedToken string) (Token, error)

func Unpack

func Unpack(packedToken string, settings UnpackSettings) (Token, error)

type UnpackSettings

type UnpackSettings struct {
	SignatureKey  string
	DecryptionKey string
}

Jump to

Keyboard shortcuts

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