auth

package
v0.0.0-...-32533e6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ClaimsContextKey contextKey = "claims"

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(secret, userID, role string, ttl time.Duration) (string, error)

func Middleware

func Middleware(secret string) func(http.Handler) http.Handler

func RequireRole

func RequireRole(role string) func(http.Handler) http.Handler

Types

type Claims

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

func ParseToken

func ParseToken(secret, tokenStr string) (*Claims, error)

type Handler

type Handler struct {
	DB     *pgxpool.Pool
	Secret string
}

func (*Handler) Login

func (h *Handler) Login(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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