用户通过身份验证后如何加载ACL / bjyauthorize?

时间:2015-09-16 01:52:51

标签: php zend-framework2 acl bjyauthorize

我已经安装了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();
    }
}

0 个答案:

没有答案