Documentation
¶
Index ¶
- Constants
- type JwtInstance
- type Option
- func WithAudience(aud string) Option
- func WithClaimExt(key string, value interface{}) Option
- func WithExpiresAt(exp int64) Option
- func WithId(jti string) Option
- func WithIssuedAt(iat int64) Option
- func WithIssuer(iss string) Option
- func WithNotBefore(nbf int64) Option
- func WithSubject(sub string) Option
Constants ¶
View Source
const ( JwtAudience = "aud" JwtExpire = "exp" JwtId = "jti" JwtIssueAt = "iat" JwtIssuer = "iss" JwtNotBefore = "nbf" JwtSubject = "sub" JwtExt = "ext" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JwtInstance ¶
type JwtInstance struct {
SecretKey []byte
}
func NewJwtInstance ¶
func NewJwtInstance(SecretKey []byte) *JwtInstance
func (JwtInstance) CreateToken ¶
func (that JwtInstance) CreateToken(options ...Option) (string, error)
GenerateJWT 生成JWT
func (JwtInstance) ParseToken ¶
func (that JwtInstance) ParseToken(tokenString string) (*jwt.Token, error)
ParseToken 解析JWT
type Option ¶
func WithAudience ¶
func WithClaimExt ¶
func WithExpiresAt ¶
func WithIssuedAt ¶
func WithIssuer ¶
func WithNotBefore ¶
func WithSubject ¶
Click to show internal directories.
Click to hide internal directories.