auth

package
v0.0.0-...-5bf2025 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextUserID = "user_id"
	ContextEmail  = "email"
	ContextRole   = "role"
)

Variables

View Source
var JwtKey []byte

Functions

func AdminMiddleware

func AdminMiddleware() gin.HandlerFunc

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

func GenerateJWT

func GenerateJWT(userID, email, role string) (string, error)

func GetUserEmail

func GetUserEmail(c *gin.Context) string

func GetUserID

func GetUserID(c *gin.Context) string

func GetUserRole

func GetUserRole(c *gin.Context) string

Types

type Claims

type Claims struct {
	UserID string `json:"user_id"`
	Email  string `json:"email"`
	Role   string `json:"role"`
	jwt.RegisteredClaims
}

func ParseJWT

func ParseJWT(tokenStr string) (*Claims, error)

Jump to

Keyboard shortcuts

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