Documentation
¶
Index ¶
- Constants
- Variables
- type ClientDevices
- type Identity
- type IdentityType
- type JWT
- func (j *JWT) CreateCustomClaims(ID uint64, UUID, username, nickName, authorityID string) JWTCustomClaims
- func (j *JWT) CreateToken(claims JWTCustomClaims) (string, error)
- func (j *JWT) GenerateAnonymousToken() (c *JWTCustomClaims, token string, expiredAt int64, err error)
- func (j *JWT) GenerateSystemToken() (c *JWTCustomClaims, token string, expiredAt int64, err error)
- func (j *JWT) GenerateToken(claims JWTCustomClaims) (token string, expiredAt int64, err error)
- func (j *JWT) ParseToken(tokenString string) (*JWTCustomClaims, error)
- func (j *JWT) RefreshToken(tokenString string) (string, error)
- type JWTCustomClaims
- type RequestInfo
- type TokenType
Constants ¶
View Source
const ( AnonymousID uint64 = 0 AnonymousUUID string = "anonymo-anonym-anonym-anonym-anonymous" AnonymousUserName string = "anonymous.d3tago" AnonymousNickName string = "Anonymous" AnonymousAuthorityID string = "group:anonymous" SystemID uint64 = 0 SystemUUID string = "system-system-system-system-system" SystemUserName string = "system.d3tago" SystemNickName string = "System" SystemAuthorityID string = "group:system" )
Variables ¶
View Source
var ( ErrTokenExpired = errors.New("Token is expired [TokenExpired]") ErrTokenNotValidYet = errors.New("Token not active yet [TokenNotValidYet]") ErrTokenMalformed = errors.New("That's not even a token [TokenMalformed]") ErrTokenInvalid = errors.New("Couldn't handle this token [IvalidToken]") )
Functions ¶
This section is empty.
Types ¶
type ClientDevices ¶
ClientDevices type
type Identity ¶
type Identity struct { IsLogin bool IsAnonymous bool TokenType TokenType Token string Claims *JWTCustomClaims ClientDevices ClientDevices RequestInfo RequestInfo // contains filtered or unexported fields }
Identity type
func NewIdentity ¶
func NewIdentity(iType IdentityType, tokenType TokenType, token string, claims *JWTCustomClaims, ctx interface{}, h *handler.Handler) (Identity, error)
NewIdentity new Identity
func (*Identity) CanAccessCurrentRequest ¶
CanAccessCurrentRequest ca access current request
func (*Identity) SetCasbinEnforcer ¶
SetCasbinEnforcer set CasbinEnforcer
type IdentityType ¶ added in v0.2.0
type IdentityType string
IdentityType Type
const ( DefaultIdentity IdentityType = "default" SystemIdentity IdentityType = "system" )
type JWT ¶
JWT type
func (*JWT) CreateCustomClaims ¶
func (j *JWT) CreateCustomClaims(ID uint64, UUID, username, nickName, authorityID string) JWTCustomClaims
CreateCustomClaims create custom claims
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims JWTCustomClaims) (string, error)
CreateToken Create a token
func (*JWT) GenerateAnonymousToken ¶
func (j *JWT) GenerateAnonymousToken() (c *JWTCustomClaims, token string, expiredAt int64, err error)
GenerateAnonymousToken generate anonymous token
func (*JWT) GenerateSystemToken ¶ added in v0.2.0
func (j *JWT) GenerateSystemToken() (c *JWTCustomClaims, token string, expiredAt int64, err error)
GenerateSystemToken generate system (identity) token
func (*JWT) GenerateToken ¶
func (j *JWT) GenerateToken(claims JWTCustomClaims) (token string, expiredAt int64, err error)
GenerateToken generate token
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*JWTCustomClaims, error)
ParseToken Parse token
type JWTCustomClaims ¶
type JWTCustomClaims struct { ID uint64 UUID string Username string NickName string AuthorityID string jwt.StandardClaims }
JWTCustomClaims represent JWT Custom claims structure
type RequestInfo ¶
RequestInfo type
Click to show internal directories.
Click to hide internal directories.