drago-ex / authorization
Simple dynamic access control list management.
v1.0.28
2024-01-12 07:20 UTC
Requires
- php: >=8.1 <8.4
- drago-ex/application: ^1.0
- drago-ex/database: ^1.0
- drago-ex/utils: ^1.0
- latte/latte: ^3.0
- nette/application: ^3.1
- nette/caching: ^3.2
- nette/di: ^3.1
- nette/security: ^3.1
- ublaboo/datagrid: dev-next
Requires (Dev)
- nette/bootstrap: ^3.2
- nette/tester: ^2.5
- phpstan/phpstan-nette: 1.2.9
- tracy/tracy: ^2.10
README
Simple dynamic access control list management.
Technology
- PHP 8.1 or higher
- Bootstrap
- composer
Installation
composer require drago-ex/authorization
Extension registration
extensions: - Drago\Authorization\DI\AuthorizationExtension
Use trait in base presenter for access control
use Drago\Authorization\Authorization // Add redirect to sign in presenter or module private string $loginLink = ':Module:Presenter:';
Use trait in presenter for settings access control
use Drago\Authorization\Control\AuthorizationControl
Component creation and configuration
// Minimum configuration. protected function createComponentPermissionsControl(): PermissionsControl { return $this->permissionsControl; } protected function createComponentRolesControl(): RolesControl { return $this->rolesControl; } protected function createComponentResourcesControl(): ResourcesControl { return $this->resourcesControl; } protected function createComponentPrivilegesControl(): PrivilegesControl { return $this->privilegesControl; } protected function createComponentAccessControl(): AccessControl { return $this->accessControl; } // Configure a custom template. $control->templateControl = __DIR__ . '/path/to/file.latte'; $control->templateGrid = __DIR__ . '/path/to/file.latte'; // Inserting a translator. $control->translator = $this->getTranslator();
Use components in latte
{control permissionsControl} {control rolesControl} {control resourcesControl} {control privilegesControl} {control accessControl}