drago-ex/project-permission

Component for managing user permissions in a Drago project.

Maintainers

Package info

github.com/drago-ex/project-permission

Type:drago-project-resource

pkg:composer/drago-ex/project-permission

Statistics

Installs: 30

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-05-13 06:29 UTC

This package is auto-updated.

Last update: 2026-05-13 06:29:23 UTC


README

Component for ACL and permission management in a Drago / Nette project.

License: MIT PHP version

Requirements

  • PHP >= 8.3
  • Nette Framework
  • Composer
  • Bootstrap
  • Naja
  • Node.js
  • Drago Project core packages

Installation

composer require drago-ex/project-permission

After installation, run the package migrations, load the provided service configuration, register the Naja extension from assets/permission-toggle.js and include styles from assets/permission-togle.scss.

Example:

import naja from 'naja';
import PermissionToggle from 'drago-ex/project-permission/assets/permission-toggle';
import 'drago-ex/project-permission/assets/permission-toggle.scss';

naja.registerExtension(new PermissionToggle());

What it does

  • manages roles
  • assigns multiple roles to users
  • manages resource + privilege records
  • allows role permissions to be toggled in the admin UI
  • builds a Nette Permission ACL from registered providers and database data

The package ships with an admin section for:

  • Users - assign roles to existing users
  • Roles - create, edit and delete custom roles
  • Permissions - allow or deny access for a selected role

System roles such as admin, user and guest are handled as protected base roles.

Database

The package works with these tables:

  • roles
  • users_roles
  • resources
  • authorization

Seed migrations also add default roles and AccessControl permissions for the backend module.

Integration with project-auth

UserRepository fill in the body of the prepared getRolesByUser() method:

public function getRolesByUser(int $userId): array
{
	$roles = $this->getConnection()
		->select('r.*')->from(RolesEntity::Table)->as('r')
		->innerJoin(UsersRolesEntity::Table)->as('ur')->on('ur.role_id = r.id')
		->where('ur.%n = ?', UsersRolesEntity::ColumnUserId, $userId)
		->fetchPairs(RolesEntity::PrimaryKey, RolesEntity::ColumnName);

	return $roles ?: [\Drago\Permission\Role::RoleUser];
}

Database migration

php vendor/bin/migration db:migrate vendor/drago-ex/project-permission/migrations

Important Note on Migrations: The migrations in this package depend on the users table. If you are not using the automated package-setup tool, ensure that you run the migrations from drago-ex/project-auth first to create the necessary foreign key targets.