-
Notifications
You must be signed in to change notification settings - Fork 143
Closed as duplicate
Labels
bugSomething isn't workingSomething isn't working
Description
PHP Version
8.3.13
CodeIgniter4 Version
4.5.5
Shield Version
1.1
Which operating systems have you tested for this bug?
Linux
Which server did you use?
fpm-fcgi
Database
SQLite3, MariaDB, Postgres
Did you customize Shield?
No
What happened?
Assigning permissions to a group using asterisk (*) does not work with multiple level properties:
(it works one level only, but, unfortunately, shield documentation does not mentions that lib limitation)
public array $permissions = [
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'admin.settings.theme' => 'Can change site theme', // this won't work with assigning permissions using asterisk (*)
...
'test.permissions.one' => 'Can access permission one', // won't work with asterisk (*)
'test.permissions.two' => 'Can access permission two', // won't work with asterisk (*)
]; public array $matrix = [
'superadmin' => [
'admin.*', // only first level will be granted (access and settings, not settings.theme
'users.*',
'sys.*',
'test.*', // no settings will be granted (or, one cannot use can() or hasPermission()
],
...
'user' => [
'test.*', // does not work
'test.permissions.*', // does'n work either
],Steps to Reproduce
Add the above config AuthGroups config class. try to check for authorization withing a controller:
if (auth()->user()->can('test.permissions.one')) {
//if (auth()->user()->hasPermission('test.permissions.one')) {
return "You CAN test.permissions.one!";
} else {
return "You CAN'T test.permissions.one!";
}Expected Output
"You CAN test.permissions.one!"
Anything else?
I suspect this limitation is related to CI4 Settings library Known Limitations.
IMHO, if this limitation is settings library responsibility, it is very counterproductive for shield to use it.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working