Can't configure AuthGroups in different namespace #1074
-
PHP Version8.3.0 CodeIgniter4 Version4.4.6 Shield Version1.0.2 Which operating systems have you tested for this bug?macOS Which server did you use?apache DatabaseMySQL 5.7.39 Did you customize Shield?No What happened?Can't get the authGroups permissions defined in the when i request a list of permissions using public array $permissions = [
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'users.manage-admins' => 'Can manage other admins',
'users.create' => 'Can create new non-admin users',
'users.edit' => 'Can edit existing non-admin users',
'users.delete' => 'Can delete existing non-admin users',
'beta.access' => 'Can access beta-level features',
]; Steps to ReproduceI am using I have namespace Modules\Auth\Config;
// other stuffs
use CodeIgniter\Shield\Config\AuthGroups as ShieldAuthGroups;
class AuthGroups extends ShieldAuthGroups
{
// other stuffs
public array $permissions = [
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'groups.settings' => 'Can access the groups settings',
'groups.edit' => 'Can edit existing user groups',
'users.list' => 'Can view a list of users in the system',
'users.manage-admins' => 'Can manage other admins',
'users.view' => 'Can view user details',
'users.create' => 'Can create new non-admin users',
'users.edit' => 'Can edit existing non-admin users',
'users.delete' => 'Can delete existing non-admin users',
'users.settings' => 'Can manage User settings in admin area',
'beta.access' => 'Can access beta-level features',
'site.viewOffline' => 'Can view the site even when in "offline" mode',
'widgets.settings' => 'Can view the settings for site Widgets',
'consent.settings' => 'Can view the settings for the Consent module',
'recycler.view' => 'Can view the Recycler area',
'logs.view' => 'Can view the logs',
'logs.manage' => 'Can manage the logs',
'me.edit' => 'Can edit user\'s own settings',
'me.security' => 'Can change user\'s own password',
];
// other stuffs
} i have another config class called namespace Modules\Languages\Config;
// other stuffs
use Modules\Auth\Config\AuthGroups as ConfigAuthGroups;
class AuthGroups extends ConfigAuthGroups
{
protected array $permissions = [
'languages.access' => 'Can access the Languages Files Management Module',
'languages.view' => 'Can view all language files',
'languages.view_single' => 'Can view individual language files',
'languages.create' => 'Can create new language files',
'languages.edit' => 'Can edit existing language files',
'languages.edit_content' => 'Can edit translations within a language file',
'languages.edit_meta' => 'Can edit metadata of a language file (e.g., name, locale)',
'languages.delete' => 'Can delete language files',
'languages.manage' => 'Can manage all aspects of language files (create, edit, delete)',
'languages.upload' => 'Can upload language files',
'languages.download' => 'Can download language files',
'languages.import' => 'Can import translations from an external source',
'languages.export' => 'Can export translations to an external source',
'languages.approve' => 'Can approve or reject changes made to a language file (for workflows)',
];
} Steps
public $psr4 = [
APP_NAMESPACE => APPPATH,
'Config' => APPPATH . 'Config',
'Modules\Auth'=> ROOTPATH.'modules/Auth/',
];
namespace Modules\Auth\Config;
// other stuffs
use CodeIgniter\Shield\Config\AuthGroups as ShieldAuthGroups;
class AuthGroups extends ShieldAuthGroups
{
// other stuffs
public array $permissions = [
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'groups.settings' => 'Can access the groups settings',
'groups.edit' => 'Can edit existing user groups',
'users.list' => 'Can view a list of users in the system',
'users.manage-admins' => 'Can manage other admins',
'users.view' => 'Can view user details',
'users.create' => 'Can create new non-admin users',
'users.edit' => 'Can edit existing non-admin users',
'users.delete' => 'Can delete existing non-admin users',
'users.settings' => 'Can manage User settings in admin area',
'beta.access' => 'Can access beta-level features',
'site.viewOffline' => 'Can view the site even when in "offline" mode',
'widgets.settings' => 'Can view the settings for site Widgets',
'consent.settings' => 'Can view the settings for the Consent module',
'recycler.view' => 'Can view the Recycler area',
'logs.view' => 'Can view the logs',
'logs.manage' => 'Can manage the logs',
'me.edit' => 'Can edit user\'s own settings',
'me.security' => 'Can change user\'s own password',
];
// other stuffs
} the methodology is inspired by Bonfire 2 Auth Module Expected Output[
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'groups.settings' => 'Can access the groups settings',
'groups.edit' => 'Can edit existing user groups',
'users.list' => 'Can view a list of users in the system',
'users.manage-admins' => 'Can manage other admins',
'users.view' => 'Can view user details',
'users.create' => 'Can create new non-admin users',
'users.edit' => 'Can edit existing non-admin users',
'users.delete' => 'Can delete existing non-admin users',
'users.settings' => 'Can manage User settings in admin area',
'beta.access' => 'Can access beta-level features',
'site.viewOffline' => 'Can view the site even when in "offline" mode',
'widgets.settings' => 'Can view the settings for site Widgets',
'consent.settings' => 'Can view the settings for the Consent module',
'recycler.view' => 'Can view the Recycler area',
'logs.view' => 'Can view the logs',
'logs.manage' => 'Can manage the logs',
'me.edit' => 'Can edit user\'s own settings',
'me.security' => 'Can change user\'s own password',
'languages.access' => 'Can access the Languages Files Management Module',
'languages.view' => 'Can view all language files',
'languages.view_single' => 'Can view individual language files',
'languages.create' => 'Can create new language files',
'languages.edit' => 'Can edit existing language files',
'languages.edit_content' => 'Can edit translations within a language file',
'languages.edit_meta' => 'Can edit metadata of a language file (e.g., name, locale)',
'languages.delete' => 'Can delete language files',
'languages.manage' => 'Can manage all aspects of language files (create, edit, delete)',
'languages.upload' => 'Can upload language files',
'languages.download' => 'Can download language files',
'languages.import' => 'Can import translations from an external source',
'languages.export' => 'Can export translations to an external source',
'languages.approve' => 'Can approve or reject changes made to a language file (for workflows)',
]; Anything else?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You misunderstand If you want to add permissions from modules, you need to use Registrars: |
Beta Was this translation helpful? Give feedback.
You misunderstand
config()
orsettings()
.config()
loads only one Config class, and if there is the class inapp/Config/
, it is loaded.If you want to add permissions from modules, you need to use Registrars:
https://codeigniter4.github.io/CodeIgniter4/general/configuration.html#registrars