glsecurity

package
v0.0.0-...-a0770fe Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiKeyHeader         = "x-api-key"
	ConsoleApiCookieName = "guardlight_session"
	ContextNameUserId    = "guardlight-user-id"
)

Variables

This section is empty.

Functions

func GetUserIdFromContextParsed

func GetUserIdFromContextParsed(ctx context.Context) uuid.UUID

func MakeJwtTokenForCompanion

func MakeJwtTokenForCompanion(u UserTokenCredentials) (string, error)

func ReuseBindAndValidate

func ReuseBindAndValidate(c *gin.Context, obj any) error

func UseGuardlightAuth

func UseGuardlightAuth() gin.HandlerFunc

func UseGuardlightAuthApiKey

func UseGuardlightAuthApiKey() gin.HandlerFunc

func ValidateData

func ValidateData(data interface{}) error

Types

type GuardlightClaims

type GuardlightClaims struct {
	jwt.MapClaims
	UserId string   `json:"userId"`
	Role   UserRole `json:"role"`
}

func VerifyAndGetClaimsForGuardlightToken

func VerifyAndGetClaimsForGuardlightToken(tkn string) (*GuardlightClaims, error)

type UserRole

type UserRole string
const (
	Admin  UserRole = "admin"
	Member UserRole = "member"
)

type UserTokenCredentials

type UserTokenCredentials struct {
	UserId uuid.UUID
	Role   UserRole
}

Jump to

Keyboard shortcuts

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