Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppClaims ¶
type AppClaims struct { Scopes []string ScopeIDs []int64 Name string Email string //more... jwtLib.StandardClaims }
AppClaims App票据声明
type Conf ¶
type Conf struct { Enable bool `yaml:"enable" toml:"enable" json:"enable"` //是否启用 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 配置信息
<yaml example>
jwt_conf:
enable: false public_key: private_key: algorithm: RS256 hmac_secret: example token_issuer: authority
<toml example>
::jwt密钥配置:: ¶
[jwt_conf]
enable = false
公钥文件或字符串 ¶
public_key = ""
私钥文件或字符串 ¶
private_key = ""
加密算法: RS256 | RS512 | HS512 ¶
algorithm = "RS256"
密钥,当algorithm = "HS512"时需要配置此项 ¶
hmac_secret = "example"
令牌颁发者 ¶
token_issuer = "authority"
func (*Conf) GetPrivateKeyObj ¶
func (c *Conf) GetPrivateKeyObj() *rsa.PrivateKey
GetPrivateKeyObj 获取私钥对象
func (*Conf) GetPublicKeyObj ¶
GetPublicKeyObj 获取公钥对象
type MapClaims ¶
type MapClaims map[string]interface{}
func VerifyFromMap ¶
VerifyFromMap 验证
type SigningMethod ¶
type SigningMethod string
SigningMethod 签名方法
const ( SigningMethodRS256 SigningMethod = "RS256" //SigningMethodRS256 rsa256方法 SigningMethodRS512 SigningMethod = "RS512" //SigningMethodRS512 rsa512方法 SigningMethodHS512 SigningMethod = "HS512" //SigningMethodHS512 hmac方法 )
Click to show internal directories.
Click to hide internal directories.