boctulus / simplerest-basic-acl
Basic ACL for SimpleRest
Requires
- php: >=8.1,<8.5
- boctulus/simplerest: ^2.0 || ^3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
boctulus/simplerest-basic-acl is a minimal concrete ACL for SimpleRest. It loads the role list from the roles table and otherwise relies on the role and permission builder of the core Boctulus\Simplerest\Core\Security\Acl. Use boctulus/simplerest-fine-grained-acl for special, per-user and deny permissions.
Installation
composer require boctulus/simplerest-basic-acl
-
Register the provider in
config/config.php:'providers' => [ Boctulus\BasicACL\BasicAclServiceProvider::class, ],
-
Create
config/acl.phpthat returns the ACL instance (Factory::acl()includes it). The roles come from therolestable, so do not add them again withaddRole(); assign permissions to the existing roles with the$to_roleargument:<?php use Boctulus\BasicACL\Acl; $acl = new Acl(); $acl->setAsGuest('guest') ->addResourcePermissions('products', ['read'], 'registered') ->addSpecialPermissions(['read_all', 'write_all'], 'admin'); return $acl;
A role without permissions, such as
guestabove, gets HTTP 401 from the generated API. -
The
rolestable must exist and contain the roles you reference. The base migrations fromvendor/bin/simplerest init(boctulus/simplerest-cli) create and seed it.
Requirements
PHP >=8.1,<8.5 and boctulus/simplerest ^2.0 || ^3.0.
License
MIT.