jwt

package
v0.0.0-...-479da69 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(claim jwtLib.Claims, conf Conf) (string, error)

Sign 签名

Types

type AppClaims

type AppClaims struct {
	Scopes   []string
	ScopeIDs []int64
	Name     string
	Email    string
	//more...
	jwtLib.StandardClaims
}

AppClaims App票据声明

func Verify

func Verify(tokenString string, conf Conf) (AppClaims, error)

Verify 验证

func (*AppClaims) GetToken

func (ac *AppClaims) GetToken(method SigningMethod, secret interface{}) (string, error)

GetToken 获取token

type Conf

type Conf struct {
	PublicKey   string `yaml:"public_key" toml:"public_key" json:"public_key"`       //公钥字符串或公钥文件地址
	PrivateKey  string `yaml:"private_key" toml:"private_key" json:"private_key"`    //私钥字符串或私钥文件地址
	Algorithm   string `yaml:"algorithm" toml:"algorithm" json:"algorithm"`          //加密算法: RS256 | RS512 | HS512
	HmacSecret  string `yaml:"hmac_secret" toml:"hmac_secret" json:"hmac_secret"`    //密钥
	TokenIssuer string `yaml:"token_issuer" toml:"token_issuer" json:"token_issuer"` //令牌颁发者
	// contains filtered or unexported fields
}

Conf 配置信息

func (*Conf) Load

func (c *Conf) Load()

Load 载入配置

type SigningMethod

type SigningMethod string

SigningMethod 签名方法

const (
	SigningMethodRS256 SigningMethod = "RS256" //SigningMethodRS256 rsa256方法
	SigningMethodRS512 SigningMethod = "RS512" //SigningMethodRS512 rsa512方法
	SigningMethodHS512 SigningMethod = "HS512" //SigningMethodHS512 hmac方法
)

Jump to

Keyboard shortcuts

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