rbac

package
v1.0.36 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RBACService

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

Service handles permission checks with set-based lookups

func NewRBACService

func NewRBACService(cfg *config.Configuration) (*RBACService, error)

NewRBACService loads roles.json from config and optimizes for fast lookups

func (*RBACService) GetRole

func (s *RBACService) GetRole(roleID string) (*Role, bool)

GetRole returns a specific role with metadata

func (*RBACService) HasPermission

func (s *RBACService) HasPermission(roles []string, entity string, action string) bool

HasPermission checks if any of the user's roles grant permission Complexity: O(roles) with O(1) lookups = ~3 operations for typical use NOTE: Never touches role.Name or role.Description - zero overhead

func (*RBACService) ListRoles

func (s *RBACService) ListRoles() []*Role

GetAllRoles returns all roles with metadata (for API endpoint) This is called rarely (only when fetching available roles for UI)

func (*RBACService) ValidateRole

func (s *RBACService) ValidateRole(roleName string) bool

ValidateRole checks if role exists in definitions

type Role

type Role struct {
	ID          string              `json:"id"`
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Permissions map[string][]string `json:"permissions"`
}

Role represents a role with metadata

Jump to

Keyboard shortcuts

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