auth

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ContextUser key = iota
	ContextRoles
)
View Source
const APIKeyHeader = "ApiKey"

Variables

View Source
var ErrUnauthorized = errors.New("not authorized")

Functions

func CacheInvalidate added in v0.9.1

func CacheInvalidate(id uuid.UUID)

func CacheSet added in v0.9.1

func CacheSet(user *AuthUser, roles []models.RoleEnum)

func IsRole

func IsRole(ctx context.Context, requiredRole models.RoleEnum) bool

func ValidateAdmin

func ValidateAdmin(ctx context.Context) error

func ValidateBot

func ValidateBot(ctx context.Context) error

func ValidateInvite

func ValidateInvite(ctx context.Context) error

func ValidateManageInvites

func ValidateManageInvites(ctx context.Context) error

func ValidateOwner

func ValidateOwner(ctx context.Context, userID uuid.UUID) error

func ValidateRole

func ValidateRole(ctx context.Context, requiredRole models.RoleEnum) error

func ValidateUserOrAdmin

func ValidateUserOrAdmin(ctx context.Context, userID uuid.UUID) error

Types

type AuthUser added in v0.9.1

type AuthUser struct {
	ID     uuid.UUID
	Name   string
	APIKey string
}

func CacheGet added in v0.9.1

func CacheGet(id uuid.UUID) (*AuthUser, []models.RoleEnum, bool)

func FromUser added in v0.9.1

func FromUser(u *models.User) *AuthUser

FromUser projects a models.User into the slim cached form.

func GetCurrentUser

func GetCurrentUser(ctx context.Context) *AuthUser

Jump to

Keyboard shortcuts

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