middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const AuthCookieName = "statora_auth"

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(jwtSecret string) gin.HandlerFunc

func GenerateToken

func GenerateToken(userID, username, secret string) (string, error)

func GenerateTokenWithClaims

func GenerateTokenWithClaims(input TokenClaimsInput) (string, error)

func RequireMFAVerified

func RequireMFAVerified() gin.HandlerFunc

func RequireRoles

func RequireRoles(allowedRoles ...string) gin.HandlerFunc

Types

type Claims

type Claims struct {
	UserID      string `json:"userId"`
	Username    string `json:"username"`
	Role        string `json:"role,omitempty"`
	MFAVerified bool   `json:"mfaVerified,omitempty"`
	jwt.RegisteredClaims
}

type TokenClaimsInput

type TokenClaimsInput struct {
	UserID      string
	Username    string
	Role        string
	MFAVerified bool
	Secret      string
	Now         time.Time
}

Jump to

Keyboard shortcuts

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