cakephp-tinyauth
cakephp-tinyauth copied to clipboard
set config - authorization
hi, using new plugins with tiny I use
$this->loadComponent('TinyAuth.Authorization',[
'multiRole' => true
]);
debug($this->Authorization->getConfig('multiRole')); // returns `true`
then I checked it in \TinyAuth\Policy\RequestPolicy
debug($this->getConfig('multiRole')); // returns `false`
this config used in RequestPolicy::canAccess() and then in AclTrait::_checkUser()
so it ignores configs
result : no way to set config when loading component
Do u have an idea for a fix? I havent used new plugins yet in prod.
there is Configure::read('TinyAuth') in TinyAuth\Utility\Config::all()
but it checks only once
public static function all() {
if (!static::$_config) {
$config = (array)Configure::read('TinyAuth') + static::$_defaultConfig;
static::$_config = $config;
}
return static::$_config;
}
and I'm not sure if this is official way or no ( no documentation for it)
and configs from component should apply to Configure::read('TinyAuth') or no?
because $this->loadComponent('TinyAuth.Authorization) loads after Application::middleware()
and a way to write configs is in Application::bootstrap()
Configure::write('TinyAuth.multiRole', true);
Feel free to make a PR with suggested fixes, and we can review it.
Any update on this? Is it possible that when using the new plugins, that we dont want to use components maybe?
Using global configure is the way here