首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用户通过身份验证后,如何加载ACL / bjyauthorize?

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

Stack Overflow用户
提问于 2015-09-16 09:52:51
回答 1查看 189关注 0票数 0

我已经安装了ZendFramework bjyauthorize。我也安装了zfcuser,但我不想使用它。我有我的另一个认证模块。我想知道在用户通过身份验证后,如何触发或加载bjyauthorize角色/ACL。

这是一个正确的提供者吗?

代码语言:javascript
复制
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();
    }
}
EN

回答 1

Stack Overflow用户

发布于 2015-09-18 20:07:32

bjyAuthorize不直接与您的身份验证模块交互。它只需要当前登录用户的角色。它通过身份提供者获得这些信息。因此,您应该扩展身份提供者的ProviderInterface,以返回属于当前登录用户的角色。

Identity provider interface

您可能还应该更改(或创建自己的)默认角色提供程序,以返回您为身份验证模块定义的角色

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32598477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档