jwt

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(secret string, payload map[string]any, options ...*SignOptions) (string, error)

Sign signs data with secret

func Verify

func Verify(secret string, token string, options ...*VerifyOptions) (*typ.Value, error)

Verify verifies data with secret

Types

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

Header is the header of JWT

type Jwt added in v1.1.6

type Jwt interface {
	Sign(payload map[string]interface{}) (string, error)
	Verify(token string) (*typ.Value, error)
}

Jwt is the jwt

func New

func New(secret string, options ...*Options) Jwt

New creates a new JWT

type Options

type Options struct {
	Issuer    string `json:"iss"`
	Subject   string `json:"sub"`
	Audience  string `json:"aud"`
	ExpiresAt int64  `json:"exp"`
	NotBefore int64  `json:"nbf"`
	IssuedAt  int64  `json:"iat"`
	JWTID     string `json:"jti"`
	Algorithm string
}

Options is the options for jwt

type Payload

type Payload struct {
	Issuer    string `json:"iss"`
	Subject   string `json:"sub"`
	Audience  string `json:"aud"`
	ExpiresAt int64  `json:"exp"`
	NotBefore int64  `json:"nbf"`
	IssuedAt  int64  `json:"iat"`
	JWTID     string `json:"jti"`
}

Payload is the payload of JWT

type SignOptions

type SignOptions struct {
	Issuer    string `json:"iss"`
	Subject   string `json:"sub"`
	Audience  string `json:"aud"`
	ExpiresAt int64  `json:"exp"`
	NotBefore int64  `json:"nbf"`
	IssuedAt  int64  `json:"iat"`
	JWTID     string `json:"jti"`
	Algorithm string
}

SignOptions is the options for Sign

type VerifyOptions

type VerifyOptions struct {
	Issuer    string `json:"iss"`
	Subject   string `json:"sub"`
	Audience  string `json:"aud"`
	ExpiresAt int64  `json:"exp"`
	NotBefore int64  `json:"nbf"`
	IssuedAt  int64  `json:"iat"`
	JWTID     string `json:"jti"`
}

VerifyOptions is the options for Verify

Jump to

Keyboard shortcuts

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