jwt

package
v2.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TokenHeaderKeyPrefix = "BEARER "

TokenHeaderKeyPrefix is a token prefix regarding RFCXXX.

Variables

View Source
var ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
View Source
var TimeFunc = time.Now

TimeFunc provides the current time when parsing token to validate "exp" claim (expiration time). You can override it to use another time value. This is useful for testing or if your server uses a time zone different from your tokens'.

Functions

func ExtractTokenFromBearerHeader

func ExtractTokenFromBearerHeader(token string) []byte

ExtractTokenFromBearerHeader extracts token from the Bearer token header value.

func GenerateNewPrivateKey

func GenerateNewPrivateKey(alg model.TokenSignatureAlgorithm) (interface{}, error)

func LoadPrivateKeyFromPEMFile

func LoadPrivateKeyFromPEMFile(file string) (interface{}, model.TokenSignatureAlgorithm, error)

LoadPrivateKeyFromPEM loads private key from PEM file.

func LoadPrivateKeyFromPEMString

func LoadPrivateKeyFromPEMString(s string) (interface{}, model.TokenSignatureAlgorithm, error)

func LoadPublicKeyFromPEM

func LoadPublicKeyFromPEM(file string) (interface{}, model.TokenSignatureAlgorithm, error)

LoadPublicKeyFromPEM loads public key from file

func LoadPublicKeyFromString

func LoadPublicKeyFromString(s string) (interface{}, model.TokenSignatureAlgorithm, error)

LoadPublicKeyFromString loads public key from string.

func Make64ColsString

func Make64ColsString(slice []byte) string

func MarshalPrivateKeyToPEM

func MarshalPrivateKeyToPEM(key interface{}) (string, error)

func MarshalPublicKeyToPEM

func MarshalPublicKeyToPEM(key interface{}) (string, error)

func ParseTokenString added in v2.3.3

func ParseTokenString(str string) (model.Token, error)

Parse parses token data from the string representation.

func ParseTokenWithPublicKey

func ParseTokenWithPublicKey(t string, publicKey interface{}) (model.Token, error)

ParseTokenWithPublicKey parses token with provided public key.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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