emiliosh / l4-ldap
Laravel 4 的 LDAP/Active Directory/NTLM 认证驱动程序。
Requires
- php: >=5.3.0
- illuminate/support: ~4
This package is not auto-updated.
Last update: 2024-09-29 03:10:16 UTC
README
Laravel 4 的 LDAP/Active Directory/NTLM 认证驱动程序。
此包将使您能够对基于 Laravel 4 的站点的任何基于身份验证的部分的管理员和观众启用基于配置的 ACL 的基本认证。此外,该包能够连接到基于 Apache 的 NTLM 认证。您需要安装并配置 php5-ldap
和 libapache2-mod-auth-ntlm-winbind
以在 Apache2 上运行(请访问 http://goo.gl/SzkuVo 获取教程)。如果没有安装,包仍然可以运行。
安装
要将此安装到您的应用程序中,请在您的 composer.json
文件中添加以下内容
require { "wells/l4-ldap-ntlm": "dev-master" }
然后根据需要运行 composer install
或 composer update
一旦您从 Packagist.org 下载了包,您需要让应用程序使用 LDAP 服务提供者。
打开 app/config/app.php
并添加以下内容
Wells\L4LdapNtlm\L4LdapNtlmServiceProvider
这告诉 Laravel 4 使用来自 vendor 文件夹的服务提供者。
您还需要将 Auth 指向使用 ldap 驱动而不是 Eloquent 或数据库。
编辑 app/config/auth.php
并将驱动程序更改为 ldap
配置
将以下配置添加到您的 app/config/auth.php
文件中
/** * LDAP Configuration for wells/l4-ldap-ntlm */ 'ldap' => array( // Domain controller (host), Domain to search (domain), // OU containing users (basedn), OU containing groups (groupdn) 'host' => 'ldap://dc', // You can also use ldaps:// 'domain' => 'domain.com', 'timeout' => 3, // Timeout in seconds (It is optional, if you don´t select it is used the default value) 'basedn' => 'OU=Users,DC=domain,DC=com', 'groupdn' => 'OU=Groups,DC=domain,DC=com', // Domain credentials the app should use to access DC // This user doesn't need any privileges 'dn_user' => '*', 'dn_pass' => '*', //At minimum, you'll need these attributes 'attributes' => array( 'dn', 'samaccountname', 'memberof' ), // Optionally require groups to gain auth view access 'groups' => array('AuthViewers'), // Optionally require group admins 'admin_groups' => array('IT'), // Optionally require owners/admins (username) 'owners' => array('ceo'), ),
用法
除了默认的 Auth 功能外,您还可以使用提供的 Guard 类中的 auto() 方法启用 NTLM 认证。编辑 app/config/filters.php
并更改为
Route::filter('auth', function() { // !Auth::user() checks to see if the user has access permission if (!Auth::auto() || Auth::guest()) return Redirect::guest('login'); });