drago-ex/authorization

Simple dynamic access control list management.

v1.0.28 2024-01-12 07:20 UTC

README

Simple dynamic access control list management.

License: MIT PHP version Tests Coding Style CodeFactor Coverage Status

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}