Documentation ¶
Index ¶
- Constants
- func ClientId(r *http.Request) string
- func DeleteTokeByToken(token string) error
- func DeleteToken(app, device, id string) error
- func GetClientName(r *http.Request) string
- func GetToken(key string) (string, error)
- func GetTokenKey(app, device, id string) string
- func GetUser(r *http.Request) et.Json
- func NewToken(id, app, name string, username, device string, duration time.Duration) (string, error)
- func SetToken(app, device, id, token string, duration time.Duration) error
- type Claim
- type ContextKey
Constants ¶
const ( MSG_TOKEN_INVALID = "Token invalido" MSG_TOKEN_INVALID_ATRIB = "Token invalido, atrib (%s)" MSG_REQUIRED_INVALID = "Solicitud invalida" ERR_INVALID_CLAIM = "Formato token invalido" ERR_AUTORIZATION = "Invalid autorization" )
Variables ¶
This section is empty.
Functions ¶
func DeleteTokeByToken ¶
* * DeleteTokeByToken * @param token string * @return error *
func DeleteToken ¶
* * DeleteToken * @param app string * @param device string * @param id string * @return error *
func GetClientName ¶
* * GetClientName * @param r *http.Request * @return et.Json *
func GetTokenKey ¶
* * GetTokenKey * @param app string * @param device string * @param id string * @return string *
func NewToken ¶
func NewToken(id, app, name string, username, device string, duration time.Duration) (string, error)
* * NewToken * @param id string * @param app string * @param name string * @param username string * @param device string * @param duration time.Duration * @return token string * @return key string * @return err error *
Types ¶
type Claim ¶
type Claim struct { Salt string `json:"salt"` ID string `json:"id"` App string `json:"app"` Name string `json:"name"` Username string `json:"username"` Device string `json:"device"` Duration time.Duration `json:"duration"` jwt.StandardClaims }
func ParceToken ¶
* * ParceToken * @param token string * @return *Claim * @return error *
func ValidToken ¶
* * ValidToken * @param token string * @return *Claim * @return error *
type ContextKey ¶
type ContextKey string
const ( ServiceIdKey ContextKey = "serviceId" ClientIdKey ContextKey = "clientId" AppKey ContextKey = "app" NameKey ContextKey = "name" SubjectKey ContextKey = "subject" UsernameKey ContextKey = "username" TokenKey ContextKey = "token" ProjectIdKey ContextKey = "projectId" ProfileTpKey ContextKey = "profileTp" ModelKey ContextKey = "model" )