我已经安装了 ZendFramework bjyauthorize。我还安装了 zfcuser,但我不想使用它。我有我的其他身份验证模块。我想知道在用户通过身份验证后如何触发或加载 bjyauthorize 角色/ACL。
这是一个正确的提供者吗?
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();
}
}