jwt

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v1.1.2

func Decode[T IPayload](bs []byte, secret []byte, payload T) error

func Encode added in v1.1.2

func Encode[T IPayload](payload T, secret []byte) []byte

Types

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

type IOpt

type IOpt[T IPayload] func(j *JWT[T])

type IPayload

type IPayload interface {
	Encode() []byte
	Decode([]byte) error
}

type JWT

type JWT[T IPayload] struct {
	// contains filtered or unexported fields
}

func New

func New[T IPayload](secret []byte, opts ...IOpt[T]) *JWT[T]

func (*JWT[T]) Decode

func (j *JWT[T]) Decode(bs []byte, pl T) error

func (*JWT[T]) Encode

func (j *JWT[T]) Encode(pl T) []byte

func (*JWT[T]) Header

func (j *JWT[T]) Header() Header

func (*JWT[T]) SetHeader added in v1.1.2

func (j *JWT[T]) SetHeader(h Header)

type User

type User struct {
	Uid     int64  `json:"u"`
	Name    string `json:"n"`
	Expired int64  `json:"exp"`
}

func (*User) Decode

func (u *User) Decode(bs []byte) error

func (*User) Encode

func (u *User) Encode() []byte

Jump to

Keyboard shortcuts

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