yetopen/yii2-usuario-ldap
最新稳定版本:v1.3.13
Composer 安装命令:
composer require yetopen/yii2-usuario-ldap
包简介
An Yii2 extension to add LDAP auth (and sync) to yii2-usuario
关键字:
README 文档
README
An yii2 extension to authenticate and/or syncronize users against LDAP for 2amigos/yii2-usuario.
Installation
The preferred way to install this extension is through composer.
Either run:
php composer.phar require --prefer-dist yetopen/yii2-usuario-ldap "*"
or add
"yetopen/yii2-usuario-ldap": "*"
to the require section of your composer.json file.
Configuration
Add in your config (config/web.php for the basic app):
//... 'bootstrap' => ['log', 'usuarioLdap'], //... 'components' => [ //... 'usuarioLdap' => [ 'class' => 'yetopen\usuarioLdap\UsuarioLdapComponent', 'ldapConfig' => [ 'hosts' => ['host.example.com'], 'base_dn' => 'dc=mydomain,dc=local', 'account_prefix' => 'cn=', 'account_suffix' => ',ou=Users,dc=mydomain,dc=local', 'use_ssl' => true, 'username' => 'bind_username', 'password' => 'bind_password', ], 'createLocalUsers' => TRUE, 'defaultRoles' => ['standardUser'], 'syncUsersToLdap' => TRUE, 'secondLdapConfig' => [ 'hosts' => ['host.example.com'], 'base_dn' => 'dc=mydomain,dc=local', 'account_prefix' => 'cn=', 'account_suffix' => ',ou=Users,dc=mydomain,dc=local', 'username' => 'bind_username', 'password' => 'bind_password', ], 'allowPasswordRecovery' => FALSE, 'passwordRecoveryRedirect' => ['/controller/action'] ], //... ]
adapting parameters to your setup.
Configuration options
- ldapConfig: all the parameters for connecting to LDAP server as documented in Adldap2
- createLocalUsers: if TRUE when a user successfully authenticate against the first LDAP server is created locally in Yii database. If FALSE a default users with ID specified in
defaultUserIdis used for the session - defaultRoles: if specified the role/s will be assigned to the users created by the extension. Can be set as an array. Default to FALSE
- secondLdapConfig: if specified this is used as LDAP server for sync the local users, if not specified this is equal to ldapConfig
- syncUsersToLdap: if TRUE changes to local users are synchronized to the second LDAP server. This includes creation and deletion of an user
- defaultUserId: if
createLocalUsersis set to FALSE must contain the ID of an user to be used as local. Defaults to-1 - allowPasswordRecovery: if TRUE it will enable password recovery process, otherwise it will redirect the LDAP users to the url specified in
passwrdRecoveryRedirect. Defaults to FALSE. - passwordRecoveryRedirect: when
allowPasswordRecoveryis set to FALSE specifies the URL where the user will be redirected when trying to recover the password. This parameter will be processed by yii\helpers\Url::to(). - logCategory: it's the log category that will be passed when the module logs something, defaults to YII2_USUARIO_LDAP
Log configuration
To log all the messages about the module in one single file, configure under targets of log config file
[
'class' => 'yii\log\FileTarget', // or another target if you prefer
// Gets all the log and exceptions messages of the module
'categories' => [
'YII2_USUARIO_LDAP',
'yetopen\usuarioLdap\NoLdapUserException',
'yetopen\usuarioLdap\LdapConfigurationErrorException',
'yetopen\usuarioLdap\MultipleUsersFoundException',
'yetopen\usuarioLdap\RoleNotFoundException',
],
'logFile' => '@runtime/logs/usuario_ldap.log', // or the log file destination that you prefer
]
统计信息
- 总下载量: 4.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2019-01-15