rubyan/ldap
Composer 安装命令:
composer require rubyan/ldap
包简介
LDAP plugin for CakePHP 3.x
关键字:
README 文档
README
LDAP Authenticate Plugin for CakePHP 3.x and AuthComponent.
based on the excellent work of queencitycodefactory/ldap
Requirements
- CakePHP 3.0
- php5-ldap module
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require rubyan/ldap
You can also add "rubyan/ldap" : "dev-master" to require section in your application's composer.json.
Enable ldap in php.ini:
extension=php_ldap.dll
Usage
In your app's config/bootstrap.php add: Plugin::load('Rubyan/LDAP');
Configuration:
Setup the authentication class settings
AppController Setup:
public function initialize() { parent::initialize(); $this->loadComponent('Flash'); $this->loadComponent('Auth', [ 'loginAction' => [ 'controller' => 'Users', 'action' => 'login' ], 'authError' => 'Insufficient privileges to view requested resources. Please login to continue!', 'authenticate' => [ 'Rubyan/LDAP.Ldap' => [ 'fields' => [ 'username' => 'username', 'password' => 'password' ], 'port' => Configure::read('Ldap.port'), 'host' => Configure::read('Ldap.host'), 'domain' => Configure::read('Ldap.domain'), 'baseDN' => Configure::read('Ldap.baseDN'), 'search' => Configure::read('Ldap.search'), 'errors' => Configure::read('Ldap.errors'), 'flash' => [ 'key' => 'ldap', 'element' => 'Flash/error', ] ] ] ]); }
Setting the Base LDAP settings
config/app.php:
/** * LDAP Configuration. * * Contains an array of settings to use for the LDAP configuration. * * ## Options * * - `domain` - The domain name to match against or auto complete so user isn't * required to enter full email address * - `host` - The domain controller hostname. This can be a closure or a string. * The closure allows you to modify the rules in the configuration without the * need to modify the LDAP plugin. One host (string) should be returned when * using closure. You can find your ldap servers with the following command: * host -t srv _ldap._tcp.YOURDOMAIN.LOCAL * - `port` - The port to use. Default is 389 and is not required. * - `search` - The attribute to search against. Usually 'UserPrincipalName' * - `baseDN` - The base DN for directory - Closure must be used here, the plugin * is expecting a closure object to be set. * - `attributes` - An array of the required attributes, e.g. ["mail", "sn", "cn"]. * Note that the "dn" is always returned irrespective of which attributes types are * requested. * - `errors` - Array of errors where key is the error and the value is the error * message. Set in session to Flash.ldap for flashing * * @link http://php.net/manual/en/function.ldap-search.php - for more info on ldap search */ 'Ldap' => [ 'domain' => 'domain.local', 'host' => function() { $hosts = [ 'host1.domain.local', 'host2.domain.local' ]; shuffle($hosts); return $hosts[0]; }, 'port' => 389, 'search' => function($username, $domain) { if (strpos($username, $domain) !== false) { // remove the @domain from username $username = str_replace('@' . $domain, '', $username); } $search = '(&(objectCategory=person)(samaccountname=' . $username. '))'; return $search; }, 'baseDN' => function($username, $domain) { if (strpos($username, $domain) !== false) { $baseDN = 'OU=Domain,DC=domain,DC=local'; } else { $baseDN = 'CN=Users,DC=domain,DC=local'; } return $baseDN; }, 'attributes' => ['samaccountname','mail', 'displayname'], 'errors' => [ 'data 773' => 'Some error for Flash', 'data 532' => 'Some error for Flash', ] ],
rubyan/ldap 适用场景与选型建议
rubyan/ldap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.21k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cakephp」 「ldap」 「authenticate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rubyan/ldap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rubyan/ldap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rubyan/ldap 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
A simple Cake3 plugin to authenticate users with Cookies.
CakePHP plugin that performs Remember-me authentication with the new cookie algorithm of version 3.5 or later
Google Authentication in Laravel
LDAP user provider bundle for Symfony 6.4
MvcCore - Extension - Auth - authentication module with automatic authentication module type detection by loaded classes.
统计信息
- 总下载量: 1.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-15