claim

package
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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 App added in v0.1.1

func App(r *http.Request) string

* * App * @param r *http.Request * @return string *

func Client added in v0.1.1

func Client(r *http.Request) et.Json

* * Client *

func ClientId

func ClientId(r *http.Request) string

* * ClientId * @param r *http.Request * @return et.Json *

func ClientName added in v0.1.1

func ClientName(r *http.Request) string

* * ClientName * @param r *http.Request * @return string *

func Data added in v0.1.1

func Data(r *http.Request) et.Json

* * Data * @param r *http.Request * @return et.Json *

func DeleteTokeByToken

func DeleteTokeByToken(token string) error

* * DeleteTokeByToken * @param token string * @return error *

func DeleteToken

func DeleteToken(app, device, id string) error

* * DeleteToken * @param app, device, id string * @return error *

func Device added in v0.1.1

func Device(r *http.Request) string

* * Device * @param r *http.Request * @return string *

func Duration added in v0.1.1

func Duration(r *http.Request) time.Duration

* * Duration * @param r *http.Request * @return time.Duration *

func GetToken

func GetToken(key string) (string, error)

* * GetToken * @param key string * @return string, error *

func GetTokenKey

func GetTokenKey(app, device, id string) string

* * GetTokenKey * @param app, device, id string * @return string *

func NewToken

func NewToken(id, app, name, username, device string, duration time.Duration) (string, error)

* * NewToken * @param id, app, name, username, device string, duration time.Duration * @return string, error *

func NewTokenData added in v0.1.1

func NewTokenData(id, app, name, username, device string, data et.Json, duration time.Duration) (string, error)

* * NewAutorization * @param id, app, name, username, device string, data et.Json, duration time.Duration * @return string, error *

func ServiceId added in v0.1.1

func ServiceId(r *http.Request) string

* * ServiceId * @param r *http.Request * @return string *

func SetToken

func SetToken(app, device, id, token string, duration time.Duration) string

* * SetToken * @param app, device, id string, token string, duration time.Duration * @return string *

func Username added in v0.1.1

func Username(r *http.Request) string

* * Username * @param r *http.Request * @return string *

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"`
	Data     et.Json       `json:"data"`
	jwt.StandardClaims
}

func ParceToken

func ParceToken(token string) (*Claim, error)

* * ParceToken * @param token string * @return *Claim, error *

func ValidToken

func ValidToken(token string) (*Claim, error)

* * ValidToken * @param token string * @return *Claim, error *

func (*Claim) ToJson

func (c *Claim) ToJson() et.Json

* * ToJson * @return et.Json *

type ContextKey

type ContextKey string
const (
	ServiceIdKey ContextKey = "serviceId"
	ClientIdKey  ContextKey = "clientId"
	AppKey       ContextKey = "app"
	NameKey      ContextKey = "name"
	DeviceKey    ContextKey = "device"
	UsernameKey  ContextKey = "username"
	DataKey      ContextKey = "data"
	DurationKey  ContextKey = "duration"
)

func (ContextKey) Int added in v0.1.1

func (c ContextKey) Int(ctx context.Context, def int) int

* * Int * @param ctx context.Context, def int * @return int *

func (ContextKey) Json added in v0.1.1

func (c ContextKey) Json(ctx context.Context, def et.Json) et.Json

* * Json * @param ctx context.Context, def et.Json * @return et.Json *

func (ContextKey) Num added in v0.1.1

func (c ContextKey) Num(ctx context.Context, def float64) float64

* * Num * @param ctx context.Context, def float64 * @return float64 *

func (ContextKey) String

func (c ContextKey) String(ctx context.Context, def string) string

* * String * @param ctx context.Context, def string * @return string *

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL