sesion

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 9 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 ClientId

func ClientId(r *http.Request) string

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

func Generate

func Generate(clientId, name, app, device string, expired time.Duration) (string, error)

* * Generate method to use in token * @param clientId string * @param name string * @param app string * @param kind string * @param device string * @param expired time.Duration * @return string * @return error *

func GetClient

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

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

func GetClientName

func GetClientName(r *http.Request) string

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

func Key

func Key(app, device, clientId string) string

* * Key return a key * @param app string * @param device string * @param clientId string * @return string *

func Set

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

* * Set * @param app string * @param device string * @param id string * @param token string * @return error *

Types

type Claim

type Claim struct {
	Salt     string        `json:"salt"`
	ClientId string        `json:"clientId"`
	Name     string        `json:"name"`
	App      string        `json:"app"`
	Device   string        `json:"device"`
	Duration time.Duration `json:"expired"`
	jwt.StandardClaims
}

func Parce

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

* * Parce * @param token string * @return *Claim * @return error *

func Valid

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

* * Valid * @param token string * @return *Claim * @return error *

func (*Claim) ToJson

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

* * ToJson method to use in Claim * @return et.Json *

type ContextKey

type ContextKey string
const (
	ServiceIdKey ContextKey = "serviceId"
	ClientIdKey  ContextKey = "clientId"
	NameKey      ContextKey = "name"
	AppKey       ContextKey = "app"
	DeviceKey    ContextKey = "device"
	DuractionKey ContextKey = "duration"
	TokenKey     ContextKey = "token"
)

func (ContextKey) String

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

Jump to

Keyboard shortcuts

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