Documentation
¶
Index ¶
- Constants
- func Decrypt(encrypted *string) error
- func Encrypt(raw string) *string
- func SetupJWT(privateKeyFile, publicKeyFile string)
- func ValidateTokenAtDB(jti string) (types.SqlUuid, bool, error)
- type CustomClaims
- type CustomerInfo
- type DBTokenValidator
- type DBTokenValidatorResult
- type JwtProps
- type ServiceInfo
Constants ¶
View Source
const ( ERROR_TOKEN_DISABLED = "ERROR_TOKEN_DISABLED" ERROR_USER_DISABLED = "ERROR_USER_DISABLED" )
View Source
const QueryAdminJwtByJti string = "select j.admin_id, a.enabled " +
"FROM jwt_access_token j " +
"INNER JOIN admins as a ON j.admin_id=a.id " +
"where j.token_id=?"
View Source
const QueryJwtByJti string = "select j.user_id, u.enabled " +
"FROM app_jwt_access_token j " +
"INNER JOIN app_users as u ON j.user_id=u.id " +
"where j.token_id=? AND j.enabled=1"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { *jwt.StandardClaims TokenType string `json:"type,omitempty"` CustomerInfo Address string `json:"address,omitempty"` UserAgent *string `json:"userAgent,omitempty"` }
func CreateToken ¶
func CreateToken(user string, customerID interface{}, expires uint64, roles *[]uint16) (*string, *CustomClaims, error)
Creates a new Token
func CreateTokenWithResource ¶
func CreateTokenWithResource(user string, customerID interface{}, expires uint64, userAgent *string, roles *[]uint16, resource string) (*string, *CustomClaims, error)
Creates a new Token with resource
Output The token The Custom Claims struct The error in case any error raises
type CustomerInfo ¶
type CustomerInfo struct { ID string `json:"id"` Username string `json:"username,omitempty"` CustomerID interface{} `json:"cid,omitempty"` Roles *[]uint16 `json:"sku,omitempty"` CustomData *interface{} `json:"customData,omitempty"` }
CustomerInfo Define some custom types were going to use within our tokens
func VerifyToken ¶
func VerifyToken(dbTokenValidator DBTokenValidator, tokenString *string) (*CustomerInfo, *types.SqlUuid, error)
func VerifyTokenWityIP ¶
func VerifyTokenWityIP(dbTokenValidator DBTokenValidator, tokenString *string, ip string) (*CustomerInfo, *types.SqlUuid, error)
func (*CustomerInfo) ContainsRoleID ¶
func (c *CustomerInfo) ContainsRoleID(roleID uint16) bool
Checks if CustomerInfo object contains any RoleServicesInfo with the
type DBTokenValidator ¶
type DBTokenValidator func(jti string) (*DBTokenValidatorResult, error)
type DBTokenValidatorResult ¶
type JwtProps ¶
type ServiceInfo ¶
Click to show internal directories.
Click to hide internal directories.