auth

package
v0.0.0-...-74bcc06 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAuthMiddleware

func AdminAuthMiddleware() gin.HandlerFunc

requires authenticated user with admin role

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

validates JWT tokens and adds user info to context

func GenerateJWT

func GenerateJWT(userID, email string, isAdmin bool) (string, error)

creates a JWT token for the user

func GetUserID

func GetUserID(c *gin.Context) (string, bool)

extracts user_id from context after AuthMiddleware

func InitializeProviders

func InitializeProviders() error

sets up all OAuth providers using goth

func OptionalAuthMiddleware

func OptionalAuthMiddleware() gin.HandlerFunc

validates JWT if present but doesn't require it

Types

type Claims

type Claims struct {
	UserID  string `json:"user_id"`
	Email   string `json:"email"`
	IsAdmin bool   `json:"is_admin"`
	jwt.RegisteredClaims
}

represents JWT claims

func ValidateJWT

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

validates a JWT token and returns the claims

Jump to

Keyboard shortcuts

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