rbac

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware implements RBAC authorization

func NewMiddleware

func NewMiddleware() *Middleware

NewMiddleware creates a new RBAC middleware

func (*Middleware) HasPermission

func (m *Middleware) HasPermission(role Role, perm Permission) bool

HasPermission checks if a role has a specific permission

func (*Middleware) Require

func (m *Middleware) Require(perm Permission) func(http.Handler) http.Handler

Require returns a middleware that enforces permission

type Permission

type Permission string

Permission represents an action permission

const (
	PermBan            Permission = "ban"
	PermUnban          Permission = "unban"
	PermList           Permission = "list"
	PermSearch         Permission = "search"
	PermMetricsRead    Permission = "metrics.read"
	PermAuditRead      Permission = "audit.read"
	PermConfigRead     Permission = "config.read"
	PermConfigWrite    Permission = "config.write"
	PermServiceControl Permission = "service.control"
)

type Role

type Role string

Role represents user roles

const (
	RoleAdmin      Role = "admin"
	RoleOperator   Role = "operator"
	RolePanelAdmin Role = "panel-admin"
	RolePanelUser  Role = "panel-user"
)

Jump to

Keyboard shortcuts

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