jwt

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignHMAC

func SignHMAC(secret string, options ...func(*JWTOptions)) (string, error)

func SignRSA

func SignRSA(privateKey *rsa.PrivateKey, options ...func(*JWTOptions)) (string, error)

func VerifyAud

func VerifyAud(val string) func(*JWTDecoded) error

func VerifyClaimAfter

func VerifyClaimAfter(key string, expectedTime time.Time) func(*JWTDecoded) error

func VerifyClaimBefore

func VerifyClaimBefore(key string, expectedTime time.Time) func(*JWTDecoded) error

func VerifyClaimEquals

func VerifyClaimEquals(key string, expected any) func(*JWTDecoded) error

func VerifyExp

func VerifyExp(skew time.Duration) func(*JWTDecoded) error

func VerifyHeaderEquals

func VerifyHeaderEquals(key string, expected any) func(*JWTDecoded) error

func VerifyIss

func VerifyIss(val string) func(*JWTDecoded) error

func VerifyNbf

func VerifyNbf(skew time.Duration) func(*JWTDecoded) error

func VerifySub

func VerifySub(val string) func(*JWTDecoded) error

func WithAud

func WithAud(val string) func(*JWTOptions)

func WithClaim

func WithClaim(key string, val any) func(*JWTOptions)

func WithExp

func WithExp(val time.Time) func(*JWTOptions)

func WithHeader

func WithHeader(key string, val any) func(*JWTOptions)

func WithIat

func WithIat(val time.Time) func(*JWTOptions)

func WithIss

func WithIss(val string) func(*JWTOptions)

func WithJti

func WithJti(val string) func(*JWTOptions)

func WithNbf

func WithNbf(val time.Time) func(*JWTOptions)

func WithSub

func WithSub(val string) func(*JWTOptions)

Types

type JWTClaims

type JWTClaims map[string]any

func (JWTClaims) GetAud

func (c JWTClaims) GetAud() string

func (JWTClaims) GetExp

func (c JWTClaims) GetExp() int64

func (JWTClaims) GetIat

func (c JWTClaims) GetIat() int64

func (JWTClaims) GetIss

func (c JWTClaims) GetIss() string

func (JWTClaims) GetJti

func (c JWTClaims) GetJti() string

func (JWTClaims) GetNbf

func (c JWTClaims) GetNbf() int64

func (JWTClaims) GetSub

func (c JWTClaims) GetSub() string

type JWTDecoded

type JWTDecoded struct {
	Headers JWTHeaders
	Claims  JWTClaims
}

func VerifyHMAC

func VerifyHMAC(secret, token string, validations ...func(*JWTDecoded) error) (*JWTDecoded, error)

func VerifyRSA

func VerifyRSA(publicKey *rsa.PublicKey, token string, validations ...func(*JWTDecoded) error) (*JWTDecoded, error)

func (*JWTDecoded) GetAlg

func (j *JWTDecoded) GetAlg() string

func (*JWTDecoded) GetAud

func (j *JWTDecoded) GetAud() string

func (*JWTDecoded) GetExp

func (j *JWTDecoded) GetExp() int64

func (*JWTDecoded) GetIat

func (j *JWTDecoded) GetIat() int64

func (*JWTDecoded) GetIss

func (j *JWTDecoded) GetIss() string

func (*JWTDecoded) GetJti

func (j *JWTDecoded) GetJti() string

func (*JWTDecoded) GetNbf

func (j *JWTDecoded) GetNbf() int64

func (*JWTDecoded) GetSub

func (j *JWTDecoded) GetSub() string

func (*JWTDecoded) GetType

func (j *JWTDecoded) GetType() string

type JWTHeaders

type JWTHeaders map[string]any

func (JWTHeaders) GetAlg

func (h JWTHeaders) GetAlg() string

func (JWTHeaders) GetType

func (h JWTHeaders) GetType() string

type JWTOptions

type JWTOptions struct {
	Headers JWTHeaders
	Claims  JWTClaims
}

Jump to

Keyboard shortcuts

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