claim

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 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 ClientId

func ClientId(r *http.Request) string

* * ClientId * @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 string * @param device string * @param id string * @return error *

func GetClientName

func GetClientName(r *http.Request) string

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

func GetToken

func GetToken(key string) (string, error)

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

func GetTokenKey

func GetTokenKey(app, device, id string) string

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

func GetUser

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

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

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 *

func SetToken

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

* * SetToken * @param app string * @param device string * @param id string * @param token string * @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"`
	jwt.StandardClaims
}

func ParceToken

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

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

func ValidToken

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

* * ValidToken * @param token string * @return *Claim * @return 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"
	SubjectKey   ContextKey = "subject"
	UsernameKey  ContextKey = "username"
	TokenKey     ContextKey = "token"
	ProjectIdKey ContextKey = "projectId"
	ProfileTpKey ContextKey = "profileTp"
	ModelKey     ContextKey = "model"
)

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