authz

package
v0.0.0-...-adb5103 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenMiss  = errors.New(500, "token miss", "token miss")
	ErrClaimsMiss = errors.New(500, "claims miss", "claims miss")
)

Functions

func NewSecurityUser

func NewSecurityUser() authz.SecurityUser

func NewToken

func NewToken(key string, expireAt time.Time, userID, roleID int64, roleKey, nickname string) (string, error)

Types

type TokenClaims

type TokenClaims struct {
	UserID   int64  `json:"user_id"`
	RoleID   int64  `json:"role_id"`
	RoleKey  string `json:"role_key"`
	Nickname string `json:"nickname"`
	gojwt.RegisteredClaims
}

func FromContext

func FromContext(ctx context.Context) (*TokenClaims, error)

func MustFromContext

func MustFromContext(ctx context.Context) *TokenClaims

Jump to

Keyboard shortcuts

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