auth

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

JWT标准中注册的声明 (建议但不强制使用) :

iss: jwt签发者 sub: jwt所面向的用户 aud: 接收jwt的一方 exp: jwt的过期时间,这个过期时间必须要大于签发时间 nbf: 定义在什么时间之前,该jwt都是不可用的. iat: jwt的签发时间 jti: jwt的唯一身份标识,主要用来作为一次性token,从而回避重放攻击。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jwt

type Jwt struct {
	SigningMethod jwt.SigningMethod
	SecretKey     []byte
	Expire        time.Duration
	Refresh       time.Duration
}

func NewJwt

func NewJwt(opts ...JwtOption) *Jwt

func (*Jwt) Encrypt

func (j *Jwt) Encrypt(data map[string]interface{}) (string, error)

func (*Jwt) Verify

func (j *Jwt) Verify(str string) (*JwtClaims, error)

type JwtClaims

type JwtClaims struct {
	// contains filtered or unexported fields
}

func (*JwtClaims) Get

func (c *JwtClaims) Get(key string) interface{}

func (*JwtClaims) GetFloat32

func (c *JwtClaims) GetFloat32(key string) float32

func (*JwtClaims) GetFloat64

func (c *JwtClaims) GetFloat64(key string) float64

func (*JwtClaims) GetInt

func (c *JwtClaims) GetInt(key string) int

func (*JwtClaims) GetInt64

func (c *JwtClaims) GetInt64(key string) int64

func (*JwtClaims) GetStr

func (c *JwtClaims) GetStr(key string) string

func (*JwtClaims) HasRefresh

func (c *JwtClaims) HasRefresh() bool

type JwtOption

type JwtOption func(*Jwt)

func JwtExpire

func JwtExpire(expire time.Duration) JwtOption

func JwtRefresh

func JwtRefresh(refresh time.Duration) JwtOption

func JwtSecretKey

func JwtSecretKey(secret string) JwtOption

func JwtSigningMethod

func JwtSigningMethod(method jwt.SigningMethod) JwtOption

Jump to

Keyboard shortcuts

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