Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultSecret = "" /* 154-byte string literal not displayed */ PTAccess PermissionType = "access" // Access to all interfaces except the generation of access Token interface PTRefresh PermissionType = "refresh" // Only the generated Access Token interface can be accessed PTCustom PermissionType = "custom" // Custom, not set the ExpirationTime field AccessTokenDuration = time.Hour * 1 RefreshTokenDuration = time.Hour * 24 * 7 )
Variables ¶
This section is empty.
Functions ¶
func TokenSecretEncode ¶
func TokenSecretEncode(ts *TokenSecret) (encoded string, err error)
Types ¶
type JwtPayload ¶
type JwtPayload struct { jwt.Payload Permission PermissionType `json:"perm"` Uid string `json:"uid"` ClientId string `json:"cid,omitempty"` Extend interface{} `json:"extend,omitempty"` }
type PermissionType ¶
type PermissionType string
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func NewToken ¶
func NewToken(s *TokenSecret) *Token
func (*Token) GenerateJwtToken ¶
func (*Token) VerifyJwtToken ¶
type TokenGenerator ¶
type TokenGenerator struct {
// contains filtered or unexported fields
}
func GetDefaultTokenGenerator ¶
func GetDefaultTokenGenerator() *TokenGenerator
GetDefaultTokenGenerator return a singleton TokenGenerator with default secret
func NewTokenGenerator ¶
func NewTokenGenerator(ts *TokenSecret) *TokenGenerator
func (*TokenGenerator) Generate ¶
func (tg *TokenGenerator) Generate(issuer string, perm PermissionType, uid string, clientId string, extend interface{}) (token string, err error)
func (*TokenGenerator) Verify ¶
func (tg *TokenGenerator) Verify(token string, payload *JwtPayload) (valid bool, err error)
type TokenSecret ¶
func GenerateTokenSecret ¶
func GenerateTokenSecret(kt KeyType) (ts *TokenSecret, err error)
func TokenSecretDecode ¶
func TokenSecretDecode(encoded string) (ts *TokenSecret, err error)
Click to show internal directories.
Click to hide internal directories.