auth

package
v0.0.0-...-17e6f81 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("invalid token")
	ErrExpiredToken = errors.New("token has expired")
)

Functions

func CheckPerm

func CheckPerm(opt Options, perms ...string) fiber.Handler

func GenerateAccessToken

func GenerateAccessToken(userid, roleid string) (string, error)

GenerateAccessToken generates token for user access.

func GenerateRefreshToken

func GenerateRefreshToken() string

func GetPermissions

func GetPermissions(c *fiber.Ctx, opt Options, roleid uuid.UUID, permName map[string]bool) (bool, error)

GetPermissions extracts permission names into a []string

func GetRolePermissions

func GetRolePermissions(role *models.Role) []string

GetRolePermissions extracts permissions from a role

func RefreshTokenMiddleware

func RefreshTokenMiddleware(opt Options) fiber.Handler

Types

type Claims

type Claims struct {
	UserID string `json:"user_id"`
	RoleID string `json:"role_id"`
	jwt.RegisteredClaims
}

func VerifyToken

func VerifyToken(tokenString string) (*Claims, error)

VerifyToken verifies the token by extracting the token and cross checking secretkey, values, signing method returns

type Options

type Options struct {
	DB      *gorm.DB
	Rclient *storage.RedisClient
	Logger  *logger.Logger
}

Jump to

Keyboard shortcuts

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