Documentation ¶
Index ¶
- Variables
- func AddSigner(name string, signer SignerMethod)
- func DeleteSigner(name string)
- func GetAllSigner() map[string]SignerMethod
- func HasSigner(name string) bool
- type ClaimMap
- type ClaimStrings
- type Claims
- type HeaderMap
- type JWT
- func (this *JWT) GetClaimsFromToken(token *Token) (MapClaims, error)
- func (this *JWT) GetHeadersFromToken(token *Token) (ParsedHeaderMap, error)
- func (this *JWT) MakeToken() (token string, err error)
- func (this *JWT) ParseToken(strToken string) (*Token, error)
- func (this *JWT) Validate(token *Token) (bool, error)
- func (this *JWT) Verify(token *Token) (bool, error)
- func (this *JWT) WithAud(aud string) *JWT
- func (this *JWT) WithClaim(key string, value any) *JWT
- func (this *JWT) WithExp(exp int64) *JWT
- func (this *JWT) WithHeader(key string, value any) *JWT
- func (this *JWT) WithIat(iat int64) *JWT
- func (this *JWT) WithIss(iss string) *JWT
- func (this *JWT) WithJti(jti string) *JWT
- func (this *JWT) WithNbf(nbf int64) *JWT
- func (this *JWT) WithOption(opts ...Option) *JWT
- func (this *JWT) WithPrivateKey(privateKey []byte) *JWT
- func (this *JWT) WithPrivateKeyPassword(password string) *JWT
- func (this *JWT) WithPublicKey(publicKey []byte) *JWT
- func (this *JWT) WithSecret(secret string) *JWT
- func (this *JWT) WithSigningMethod(method string) *JWT
- func (this *JWT) WithSub(sub string) *JWT
- type Keyfunc
- type MapClaims
- type NumericDate
- type Option
- func WithAud(aud string) Option
- func WithClaim(key string, value any) Option
- func WithExp(exp int64) Option
- func WithHeader(key string, value any) Option
- func WithIat(iat int64) Option
- func WithIss(iss string) Option
- func WithJti(jti string) Option
- func WithNbf(nbf int64) Option
- func WithPrivateKey(privateKey []byte) Option
- func WithPrivateKeyPassword(password string) Option
- func WithPublicKey(publicKey []byte) Option
- func WithSecret(secret string) Option
- func WithSigningMethod(method string) Option
- func WithSub(sub string) Option
- type ParsedHeaderMap
- type Parser
- type RegisteredClaims
- type Signer
- type SignerMethod
- type SigningMethod
- type StandardClaims
- type Token
Constants ¶
This section is empty.
Variables ¶
View Source
var DecodeSegment = jwt.DecodeSegment
DecodeSegment(seg string) ([]byte, error)
View Source
var DefaultSignerList = map[string]SignerMethod{ "HS256": signer.SignerHS256, "HS384": signer.SignerHS384, "HS512": signer.SignerHS512, "RS256": signer.SignerRS256, "RS384": signer.SignerRS384, "RS512": signer.SignerRS512, "PS256": signer.SignerPS256, "PS384": signer.SignerPS384, "PS512": signer.SignerPS512, "ES256": signer.SignerES256, "ES384": signer.SignerES384, "ES512": signer.SignerES512, "EdDSA": signer.SignerEdDSA, "GmSM2": signer.SignerGmSM2, }
验证方式列表
View Source
var EncodeSegment = jwt.EncodeSegment
EncodeSegment(seg []byte) string
View Source
var GetSigningMethod = jwt.GetSigningMethod
获取注册的方法 GetSigningMethod(alg string) (method SigningMethod)
View Source
var NewJWT = jwt.New
New(method SigningMethod) *Token
View Source
var NewWithClaims = jwt.NewWithClaims
NewWithClaims(method SigningMethod, claims Claims) *Token
View Source
var Parse = jwt.Parse
Parse(tokenString string, keyFunc Keyfunc, options ...ParserOption) (*Token, error)
View Source
var ParseWithClaims = jwt.ParseWithClaims
ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc, options ...ParserOption) (*Token, error)
View Source
var RegisterSigningMethod = jwt.RegisterSigningMethod
注册签名方法 RegisterSigningMethod(alg string, f func() SigningMethod)
View Source
var TimeFunc = jwt.TimeFunc
TimeFunc = time.Now
Functions ¶
Types ¶
type JWT ¶
type JWT struct { // 头数据 Headers HeaderMap // 载荷 Claims ClaimMap // 签名方法 SigningMethod string // 秘钥 Secret string // 私钥 PrivateKey []byte // 公钥 PublicKey []byte // 私钥密码 PrivateKeyPassword string }
*
- JWT *
- @create 2021-9-15
- @author deatil
func (*JWT) GetClaimsFromToken ¶
从 token 获取解析后的[载荷]数据
func (*JWT) GetHeadersFromToken ¶
func (this *JWT) GetHeadersFromToken(token *Token) (ParsedHeaderMap, error)
从 token 获取解析后的[Header]数据
func (*JWT) WithPrivateKeyPassword ¶
私钥密码
type Option ¶ added in v1.0.1003
type Option func(*JWT)
func WithPrivateKeyPassword ¶ added in v1.0.1003
私钥密码
type Signer ¶ added in v1.0.1003
type Signer struct {
// contains filtered or unexported fields
}
*
- 签名 *
- @create 2023-2-5
- @author deatil
var DefaultSigner *Signer
默认
func (*Signer) AddSigner ¶ added in v1.0.1003
func (this *Signer) AddSigner(name string, signer SignerMethod)
注册
func (*Signer) GetAllSigner ¶ added in v1.0.1003
func (this *Signer) GetAllSigner() map[string]SignerMethod
获取全部
func (*Signer) GetSigner ¶ added in v1.0.1003
func (this *Signer) GetSigner(name string) SignerMethod
获取
type SignerMethod ¶ added in v1.0.1003
type SignerMethod = func(config.SignerConfig) interfaces.Signer
签名方法
Source Files ¶
Click to show internal directories.
Click to hide internal directories.