-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
about acl with database #207
Comments
With the latest version of InitializationThe initialization will create the
function _dev($devtools,$config){
$config=\Ubiquity\controllers\Startup::$config;
\Ubiquity\security\acl\AclManager::initializeDAOProvider($config, 'default');
$dao=new \Ubiquity\security\acl\persistence\AclDAOProvider($config);
$dao->createModels(); //Optional
echo Console::showInfo("Development mode");
}
Ubiquity bootstrap dev The generated models are particular, since they simply inherit from the corresponding ACL classes: namespace models;
/**
* Class Role
*/
class Role extends \Ubiquity\security\acl\models\Role{
} Configuration
\Ubiquity\security\acl\AclManager::start();
\Ubiquity\security\acl\AclManager::initFromProviders([
new \Ubiquity\security\acl\persistence\AclDAOProvider($config, [
'acl'=>\models\AclElement::class,
'role'=>\models\Role::class,
'resource'=>\models\Resource::class,
'permission'=>\models\Permission::class
]),
new \Ubiquity\security\acl\persistence\AclCacheProvider()
]);
UseAfter starting the project, with the Webtools, you should see the ALC interface modified: You can add ACL elements via the Or in the models part: Or in the code, like for cached ACLs: //Adding a new ACLElement
//Note that the role, permission or resource are added if they do not already exist
AclManager::addAndAllow('@USER', 'MyAclController.forUserWrite', 'WRITE');
//Adding a new role inheriting from @USER
AclManager::addRole('@CHILD', ['@USER']);
//Adding a new permission with level 500
AclManager::addPermission('MANAGE', 500);
//Adding a new resource
AclManager::addResource('MyController'); Demo projectI added a new project in the demos to illustrate this: acl-db-project |
Update on initializationIt is possible to make it easier to initialize the AclDAOProvider, with the new version of devtools ( composer global update
composer update Then execute the following command to create the tables and models (you must always have a database created and configured before). Ubiquity acl-init -p=dao -m
|
I will test it, really thanks @jcheron |
Could you please explain a little more the definition of ACL in database, because I want to make an application where you can remove or give permissions to users resources dynamically. For example to a user x give permission to the action update and at a given time remove this ability. This without touching the code, only by a web panel and database.
secondary, I would also like to know how to make an extension for ubiquity, to convert above described into an ubiquity extension for example called acl-ui.
really thanks
The text was updated successfully, but these errors were encountered: