armenio/armenio-zf2-restrictaccess-module 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

armenio/armenio-zf2-restrictaccess-module

Composer 安装命令:

composer require armenio/armenio-zf2-restrictaccess-module

包简介

Restrict Access (Database|Ldap) Module for Zend Framework 2

README 文档

README

The Restrict Access Module for Zend Framework 2

How to install

  1. Install via composer. Don't know how? Look here

  2. cd my/project/directory

  3. Edit composer.json :

    {
    	"require": {
    		"armenio/armenio-zf2-restrictaccess-module": "1.*"
    	}
    }
  4. Edit config/application.config.php :

    'modules' => array(
    	 'Application',
    	 'RestrictAccess', //<==============================
    )
  5. Edit module/config/module.config.php

    	'service_manager' => array(
            'factories' => array(
                'AuthenticationService' => function(\Zend\ServiceManager\ServiceManager $serviceManager) {
                    $service = new \RestrictAccess\Service\Authentication\DbTableService();
                    // $service = new \RestrictAccess\Service\Authentication\LdapService();
                    
                    $service->setServiceManager($serviceManager);
    
                    return $service;
                }
            ),
        ),
  6. Usage inside Controllers

    6.1 Use with Zend\Db

    $username = $data['username'];
    $password = $data['password'];
    
    $authService = $this->getServiceLocator()->get('AuthenticationService');
    
    $authService->setNamespace('Default');
    $authService->setTableName('users');
    $authService->setIdentityColumn('username');
    $authService->setCredentialColumn('password');
    
    $authenticationResult = $authService->authenticate($username, $password);
    
    if( ! $authenticationResult->isValid() ){
    	var_dump($authenticationResult->getMessages());
    }
    // else var_dump($authService->getIdentity());

    6.2 Use with Zend\Ldap

    $username = $post['username'];
    $password = $post['password'];
    
    $ldapOptions = array(
    	'server1' => array(
    		'host' => 'dc1.w.net',
    		'useStartTls' => 'false',
    		'useSsl' => 'false',
    		'baseDn' => 'CN=Users,DC=w,DC=net',
    		'accountCanonicalForm' => 3,
    		'accountDomainName' => 'w.net',
    		'accountDomainNameShort' => 'W',
    	),
    );
    
    $authService = $this->getServiceLocator()->get('AuthenticationService');
    
    $authService->setNamespace('Default');
    $authService->setOptions($ldapOptions);
    
    $authenticationResult = $authService->authenticate($username, $password);
    
    if( ! $authenticationResult->isValid() ){
    	var_dump($authenticationResult->getMessages());
    }
    // else var_dump($authService->getIdentity());
  7. Getting user identity

    if( $authService->hasIdentity() ){
    	var_dump($authService->getIdentity());
    }

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固