I have installed ZendFramework bjyauthorize. I also installed zfcuser, but I dont want to use that. I have my other authenication module. I would like to know how I can trigger or load the bjyauthorize roles/ACL, after user gets authenticated.
Is this a correct provider?
namespace Firewall\Provider\Identity;
//use BjyAuthorize\Provider\Identity;
//use BjyAuthorize\Exception\InvalidRoleException;
//use Zend\Db\Adapter\Adapter;
//use Zend\Db\Sql\Where;
//use Zend\Db\Sql\Sql;
//use Zend\Db\Sql\Select;
//use Zend\Permissions\Acl\Role\RoleInterface;
//use Zend\Authentication\Storage\Session as SessionStorage;
//use BjyAuthorize\Provider\Identity\ProviderInterface;
//use Zend\Db\TableGateway\TableGateway;
//use Zend\Db\Sql\Expression;
//use Zend\Authentication\AuthenticationService;
//
//class Myprovider implements ProviderInterface {
//
//
//
//public function setDbAdapter();
//public function getDbAdapter();
//public function getIdentityRoles();
//public function getDefaultRole();
//public function getRoles();
//
//}
use BjyAuthorize\Provider\Identity\ProviderInterface;
use Zend\Authentication\AuthenticationService;
class Myprovider implements ProviderInterface
{
// public function getDefaultRole()
// {
// $aTest = "test";
// return new Debug();
// }
public function getIdentityRoles()
{
$oIdentity = $this->getIdentity();
$aRoles = [];
if(!empty($oIdentity))
{
$aRoles = $oIdentity->getRoles();
}
return $aRoles;
}
protected $authService;
public function __construct(AuthenticationService $authService)
{
$this->authService = $authService;
}
public function setAdapter($adapter)
{
return $this->authService->setAdapter($adapter);
}
public function getAdapter()
{
return $this->authService->getAdapter();
}
public function getStorage()
{
return $this->authService->getStorage();
}
public function getIdentity()
{
return $this->authService->getIdentity();
}
public function clearIdentity()
{
return $this->authService->clearIdentity();
}
}
bjyAuthorize doesn't directly interact with your authentication module. It just needs the role of the currently signed in user. It gets that through the identity provider. So you should extend the ProviderInterface for the identity provider to return the roles that belong to the currently signed in user.
You should probably also change (or make your own) the default role provider to return the roles that you defined for your authentication module