flexcoders / opauth-ldap
Opauth 的 Ldap 策略
0.2
2015-05-04 19:53 UTC
Requires
- php: >=5.2.0
- opauth/opauth: >=0.2.0
This package is auto-updated.
Last update: 2024-09-04 23:19:21 UTC
README
Opauth 的 Ldap 认证策略。
Opauth 是一个多提供者认证框架,适用于 PHP。
入门
-
安装 Opauth-Ldap
cd path_to_opauth/Strategy git clone git://github.com/flexcoders/opauth-ldap.git ldap
-
配置 Opauth-Ldap 策略。
-
调用它。
由于这不是基于 HTTP 协议的协议,一些标准的 Opauth 配置不适用。没有涉及重定向,需要传递用户名和密码。
您可以这样调用它
// some input vars
$providerName = "Ldap";
// prep a config
$config = [
'provider' => $providerName,
'username' => $_POST['username'],
'password' => $_POST['password'],
'request_uri' => '/current/uri/'.strtolower($providerName),
'callback_url' => '/your/uri/for/callback/'.strtolower($providerName),
];
// construct the Opauth object
$this->opauth = new \Opauth($config, true);
它将尝试进行 LDAP 登录,然后重定向到回调 URL,就像其他所有 Opauth 策略一样,并具有类似的响应。
策略配置
必需参数
<?php 'Ldap' => array( 'server' => 'ldap.forumsys.com', 'port' => 389, 'bind-cn' => 'uid=$username$', 'bind-dn' => 'dc=example,dc=com', 'bind-password' => '$password$', 'attributes' => array( 'uid' => 'uidnumber', 'name' => 'cn', 'email' => 'mail', 'username' => 'uid', ), 'options' => array( LDAP_OPT_PROTOCOL_VERSION => 3, LDAP_OPT_REFERRALS => 0, ), 'expiry' => 86400, )
可选参数: expire
, options
bind() 发生在 'bind-cn' 和 'bind-dn' 的连接以及 'bind-password'。
请确保属性数组包含正确的属性映射。左侧是策略期望的名称。如果在您的模式中它们有不同的名称,请使用右侧的名称。
例如,我们需要一个名为 'name' 的属性,在模式中称为 'cn'。'email' 也是一样,在测试服务器的模式中称为 'mail'。
参考
如果您想使用互联网上的 LDAP 服务器进行测试,可以使用上面给出的配置。有关使用的 LDAP 模式和测试服务器对象的更多信息,请参阅http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
许可证
Opauth-Ldap 是 MIT 许可的版权所有 © 2015 FlexCoders Ltd (http://flexcoders.co.uk)