Documentation ¶
Index ¶
- Variables
- func AddSigner(name string, method SignerMethod)
- func DeleteSigner(name string)
- func GetAllSigner() map[string]SignerMethod
- func HasSigner(name string) bool
- type ClaimMap
- type ClaimStrings
- type Claims
- type Config
- type ECDSA
- type EdDSA
- type GmSM2
- type HeaderMap
- type Hmac
- type IConfig
- type ISigner
- 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 RSA
- 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 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 Config ¶ added in v1.0.1005
type Config struct {
// contains filtered or unexported fields
}
配置信息
func NewConfig ¶ added in v1.0.1005
func NewConfig( secret string, privateKey []byte, publicKey []byte, privateKeyPassword string, ) Config
构造函数
func (Config) PrivateKey ¶ added in v1.0.1005
func (Config) PrivateKeyPassword ¶ added in v1.0.1005
type ECDSA ¶ added in v1.0.1005
type ECDSA struct { // 配置 Config IConfig // 签名 SigningMethod jwt.SigningMethod }
*
- ECDSA *
- @create 2023-2-5
- @author deatil
func (ECDSA) GetSignSecrect ¶ added in v1.0.1005
签名密钥
func (ECDSA) GetVerifySecrect ¶ added in v1.0.1005
验证密钥
type EdDSA ¶ added in v1.0.1005
type EdDSA struct { // 配置 Config IConfig // 签名 SigningMethod jwt.SigningMethod }
*
- EdDSA *
- @create 2023-2-5
- @author deatil
func (EdDSA) GetSignSecrect ¶ added in v1.0.1005
签名密钥
func (EdDSA) GetVerifySecrect ¶ added in v1.0.1005
验证密钥
type GmSM2 ¶ added in v1.0.1005
type GmSM2 struct { // 配置 Config IConfig // 签名 SigningMethod jwt.SigningMethod }
*
- GmSM2 *
- @create 2023-2-5
- @author deatil
func (GmSM2) GetSignSecrect ¶ added in v1.0.1005
签名密钥
func (GmSM2) GetVerifySecrect ¶ added in v1.0.1005
验证密钥
type Hmac ¶ added in v1.0.1005
type Hmac struct { // 配置 Config IConfig // 签名 SigningMethod jwt.SigningMethod }
*
- Hmac *
- @create 2023-2-5
- @author deatil
func (Hmac) GetSignSecrect ¶ added in v1.0.1005
签名密钥
func (Hmac) GetVerifySecrect ¶ added in v1.0.1005
验证密钥
type IConfig ¶ added in v1.0.1005
type IConfig interface { // 秘钥 Secret() string // 私钥 PrivateKey() []byte // 公钥 PublicKey() []byte // 私钥密码 PrivateKeyPassword() string }
*
- 配置接口 *
- @create 2023-4-5
- @author deatil
type ISigner ¶ added in v1.0.1005
type ISigner interface { // 获取签名 GetSigner() jwt.SigningMethod // 签名密钥 GetSignSecrect() (any, error) // 验证密钥 GetVerifySecrect() (any, error) }
*
- 签名数据接口 *
- @create 2023-2-5
- @author deatil
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 RSA ¶ added in v1.0.1005
type RSA struct { // 配置 Config IConfig // 签名 SigningMethod jwt.SigningMethod }
*
- RSA *
- @create 2023-2-5
- @author deatil
func (RSA) GetSignSecrect ¶ added in v1.0.1005
签名密钥
func (RSA) GetVerifySecrect ¶ added in v1.0.1005
验证密钥
type Signer ¶ added in v1.0.1003
type Signer struct {
// contains filtered or unexported fields
}
*
- 签名 *
- @create 2023-2-5
- @author deatil
func (*Signer) AddSigner ¶ added in v1.0.1003
func (this *Signer) AddSigner(name string, method 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
签名方法
Source Files ¶
Click to show internal directories.
Click to hide internal directories.