Documentation
¶
Index ¶
- Constants
- func ClientId(r *http.Request) string
- func ClientName(r *http.Request) string
- func DeleteTokeByToken(token string) error
- func DeleteToken(app, device, id string) error
- func Device(r *http.Request) string
- func GenToken(c Claim, secret string) (string, error)
- func GetClient(r *http.Request) et.Json
- func GetToken(key string) (string, error)
- func GetTokenKey(app, device, id string) string
- func NewAuthorization(id, app, name, username, device, tenantId, profileTp string, ...) (string, error)
- func NewEphemeralToken(id, app, name, username, device, tag string, duration time.Duration) (string, error)
- func NewToken(id, app, name, username, device string, duration time.Duration) (string, error)
- func ProfileTp(r *http.Request) string
- func ServiceId(r *http.Request) string
- func SetToken(app, device, id, token string, duration time.Duration) error
- func Tag(r *http.Request) string
- func TenantId(r *http.Request) string
- func Username(r *http.Request) string
- type Claim
- type ContextKey
Constants ¶
const ( MSG_TOKEN_INVALID = "Token invalido" MSG_TOKEN_INVALID_ATRIB = "Token invalido, atrib (%s)" MSG_TOKEN_EXPIRED = "Token expirado" MSG_REQUIRED_INVALID = "Solicitud invalida" ERR_INVALID_CLAIM = "Formato token invalido" ERR_AUTORIZATION = "Invalid autorization" )
Variables ¶
This section is empty.
Functions ¶
func ClientName ¶ added in v0.1.1
* * ClientName * @param r *http.Request * @return string *
func DeleteTokeByToken ¶
* * DeleteTokeByToken * @param token string * @return error *
func DeleteToken ¶
* * DeleteToken * @param app, device, id string * @return error *
func GetTokenKey ¶
* * GetTokenKey * @param app, device, id string * @return string *
func NewAuthorization ¶ added in v0.1.19
func NewAuthorization(id, app, name, username, device, tenantId, profileTp string, duration time.Duration) (string, error)
* * NewAuthorization * @param id, app, name, username, device string, tenantId, profileTp string, duration time.Duration * @return string, error *
func NewEphemeralToken ¶ added in v0.1.19
func NewEphemeralToken(id, app, name, username, device, tag string, duration time.Duration) (string, error)
* * NewEphemeralToken * @param id, app, name, username, device, tag string, duration time.Duration * @return string, error *
func NewToken ¶
* * NewToken * @param id, app, name, username, device string, duration time.Duration * @return string, string, error *
func SetToken ¶
* * SetToken * @param app, device, id, token string, duration time.Duration * @return 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"`
TenantId string `json:"tenantId"`
ProfileTp string `json:"profileTp"`
Tag string `json:"tag"`
jwt.StandardClaims
}
func NewClaim ¶ added in v0.1.19
func NewClaim(id, app, name, username, device, tenantId, profileTp, tag string, duration time.Duration) Claim
* * NewClaim * @param id, app, name, username, device, tag string, duration time.Duration, tenantId, profileTp string * @return Claim *
func ParceToken ¶
* * ParceToken * @param token string * @return *Claim, error *
func ValidToken ¶
* * ValidToken * @param token string * @return *Claim, error *
type ContextKey ¶
type ContextKey string
const ( ServiceIdKey ContextKey = "serviceId" ClientIdKey ContextKey = "clientId" AppKey ContextKey = "app" DeviceKey ContextKey = "device" DurationKey ContextKey = "duration" NameKey ContextKey = "name" SubjectKey ContextKey = "subject" UsernameKey ContextKey = "username" TokenKey ContextKey = "token" TenantIdKey ContextKey = "tenantId" ProfileTpKey ContextKey = "profileTp" ModelKey ContextKey = "model" TagKey ContextKey = "tag" )