Documentation ¶
Index ¶
- Constants
- Variables
- type ClientDevices
- type Identity
- 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 TheIdentityType
- type TokenType
Constants ¶
View Source
const ( // AnonymousID represent default AnonymousID AnonymousID uint64 = 0 // AnonymousUUID represent default AnonymousUUID AnonymousUUID string = "anonymo-anonym-anonym-anonym-anonymous" // AnonymousUserName represent default AnonymousUserName AnonymousUserName string = "anonymous.d3tago" // AnonymousNickName represent default AnonymousNickName AnonymousNickName string = "Anonymous" // AnonymousAuthorityID represent default AnonymousAuthorityID AnonymousAuthorityID string = "group:anonymous" // SystemID represent default SystemID SystemID uint64 = 0 // SystemUUID represent default SystemUUID SystemUUID string = "system-system-system-system-system" // SystemUserName represent default SystemUserName SystemUserName string = "system.d3tago" // SystemNickName represent default SystemNickName SystemNickName string = "System" // SystemAuthorityID represent default SystemAuthorityID SystemAuthorityID string = "group:system" )
Variables ¶
View Source
var ( // ErrTokenExpired represent Error for TokenExpired ErrTokenExpired = errors.New("Token is expired [TokenExpired]") // ErrTokenNotValidYet represent Error for TokenNotValidYet ErrTokenNotValidYet = errors.New("Token not active yet [TokenNotValidYet]") // ErrTokenMalformed represent Error for TokenMalformed ErrTokenMalformed = errors.New("That's not even a token [TokenMalformed]") // ErrTokenInvalid represent Error for TokenInvalid 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 represent Identity
func NewIdentity ¶
func NewIdentity(iType TheIdentityType, 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 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 ¶
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
type TheIdentityType ¶
type TheIdentityType string
TheIdentityType represent TheIdentityType
const ( // DefaultIdentity represent Default Identity DefaultIdentity TheIdentityType = "default" // SystemIdentity represent System Identity SystemIdentity TheIdentityType = "system" )
Click to show internal directories.
Click to hide internal directories.