I’m using the Authentication and Authorization Middleware/Component tools in CakePHP4.x
I would find it convenient to have the Identity object in my Table classes since it can do the scope
authorization processes. But getting foreign bodies into Tables has always been tricky for me.
The object is on the Request; unavailable in Tables.
Any suggestions? In the past I’ve written an override of the table factory that let me set my own properties of Tables on construction but this seems heavy handed.
Am I missing an easy solution?
UPDATE
I realized that just because the core table class restricts the config keys that can be used, there is no reason my Table class can’t expand the list.
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config) : void {
if (!empty($config['Identity'])) {
$this->Identity = $config['Identity'];
}
if (!empty($config['authorization_scope'])) {
$this->Identity = $config['authorization_scope'];
}
parent::initialize($config);
$this->configureStackCache();
$this->validateRoot();
}