middleware

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPermissionDenied = errors.Forbidden("PERMISSION_DENIED", "permission denied")
)

Functions

func GetUserFromContext added in v0.5.0

func GetUserFromContext(ctx context.Context) (*model.User, bool)

GetUserFromContext extracts the user from context

func IsAdmin added in v0.5.0

func IsAdmin(ctx context.Context) bool

IsAdmin checks if the current request is from admin

func NewAuthorizationMiddleware added in v0.5.0

func NewAuthorizationMiddleware(aclRepo data.ACLRepository, logger log.Logger) middleware.Middleware

NewAuthorizationMiddleware creates an authorization middleware

Types

type AuthMiddleware

type AuthMiddleware interface {
	NewAuthMiddleware() middleware.Middleware
}

func CreateAuthMiddleware

func CreateAuthMiddleware(cfg *config.Auth, userRepo data.UserRepository, logger log.Logger) (AuthMiddleware, error)

func NewACLAuth added in v0.5.0

func NewACLAuth(adminToken string, userRepo data.UserRepository, logger log.Logger) AuthMiddleware

NewACLAuth returns an ACL-aware auth middleware Supports both admin static token and user/bot tokens from database

func NewNoAuth

func NewNoAuth() AuthMiddleware

NewNoAuth returns a no auth middleware It doesn't require any token

func NewStaticTokenAuth

func NewStaticTokenAuth(token string) AuthMiddleware

NewStaticTokenAuth returns a simple token auth middleware We pass the static token and use it to auth

Jump to

Keyboard shortcuts

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