问题描述
我试图使用新LdapUserProvider中的Symfony 2.8。我相信我已经配置好了一切。
我的用户可以成功进行身份验证,然后被重定向到安全页面。重定向后,问题开始的地方。 Symfony的尝试绑定作为身份验证的用户,但有一个空密码,这是开放的LDAP拒绝。
下面是相关的日志条目和配置值。
配置:
服务:
app.ldap:
等级:Symfony的\\分量\\的Ldap \\的ldapclient
参数:[本地主机]
安全性:
安全性:
防火墙:
管制区:
供应商:APP_USERS
form_login_ldap:
服务:app.ldap
dn_string:UID = {用户名},DC = MYDOMAIN,DC =净
check_path:login_check
login_path:登录
供应商:
APP_USERS:
LDAP:
服务:app.ldap
base_dn:DC = MYDOMAIN,DC =网
search_dn:CN =经理,DC = MYDOMAIN,DC =网
search_password:secretPassword的
过滤器:(及(aptAccountEnabled = 1)(对象类= aptAccount)(UID = {用户名}))
default_roles:ROLE_USER
和日志文件:
[2015年12月18日十三时55分十一秒] request.INFO:匹配路由login_check。 {\"route_parameters\":{\"_route\":\"login_check\"},\"request_uri\":\"http://ancdev.admin.aptalaska.net/~dmorphis/Portal/web/app_dev.php/Login/Verify\"} []
[2015年12月18日13时55分11秒] security.DEBUG:阅读从会话现有的安全令牌。 {关键:_ security_restricted_area} []
[2015年12月18日13时55分11秒] security.DEBUG:用户从一个用户提供程序加载。 {用户名:dan.smartrg,商:Symfony的\\\\ \\\\组件安全\\\\ \\\\核心用户\\\\ LdapUserProvider} []
[2015年12月18日13时55分二十六秒] security.INFO:用户成功验证。 {用户名:dan.smartrg} []
<&剪断GT;
[2015年12月18日13时55分二十六秒] security.DEBUG:存储在会话的安全令牌。 {关键:_ security_restricted_area} []
<&剪断GT;
[2015年12月18日13时55分27秒] request.INFO:匹配路由home.index。 {\"route_parameters\":{\"_controller\":\"Apt\\\\PortalBundle\\\\Controller\\\\DefaultController::indexAction\",\"_route\":\"home.index\"},\"request_uri\":\"http://ancdev.admin.aptalaska.net/~dmorphis/Portal/web/app_dev.php/\"} []
[2015年12月18日13时55分28秒] security.DEBUG:阅读从会话现有的安全令牌。 {关键:_ security_restricted_area} []
[2015年12月18日13时55分28秒] security.DEBUG:用户从一个用户提供程序加载。 {用户名:dan.smartrg,商:Symfony的\\\\ \\\\组件安全\\\\ \\\\核心用户\\\\ LdapUserProvider} []
[2015年12月18日十三点56分15秒] php.DEBUG:的ldap_bind():无法绑定到服务器:服务器是不愿意执行{\"type\":2,\"file\":\"/home/dmorphis/public_html/Portal/vendor/symfony/symfony/src/Symfony/Component/Ldap/LdapClient.php\",\"line\":73,\"level\":28928} []
[2015年12月18日十三点56分15秒] app.ERROR:错误的凭据。 [{\"file\":\"/home/dmorphis/public_html/Portal/app/cache/dev/classes.php\",\"line\":2697,\"function\":\"authenticate\",\"class\":\"Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Provider\\\\UserAuthenticationProvide &所述截短GT;
[2015年12月18日十三点56分15秒] security.INFO:一个的AuthenticationException被抛出;重定向到身份验证入口点。
最后,我发现是什么问题。
您必须链 UserProvider
:
chain_provider:
链:
供应商:[in_memory,APP_USERS]
在记忆中:
内存:〜
APP_USERS:
LDAP:
.....< I&GT /;
I'm trying to use the new LdapUserProvider in Symfony 2.8. I believe I have configured everything per the docs.
My user can successfully authenticate, and then gets redirected to the secured page. After the redirection is where the issue begins. Symfony tries to bind as the authenticated user, but with a null password, which is rejected by open ldap.
Here are the relevant log entries and config values.
Config:
services:
app.ldap:
class: Symfony\Component\Ldap\LdapClient
arguments: [ "localhost" ]
Security:
security:
firewalls:
restricted_area:
provider: app_users
form_login_ldap:
service: app.ldap
dn_string: "uid={username},DC=mydomain,DC=net"
check_path: login_check
login_path: login
providers:
app_users:
ldap:
service: app.ldap
base_dn: dc=mydomain,dc=net
search_dn: cn=Manager,DC=mydomain,DC=net
search_password: secretPassword
filter: "(&(aptAccountEnabled=1)(ObjectClass=aptAccount)(uid={username}))"
default_roles: ROLE_USER
And the log file:
[2015-12-18 13:55:11] request.INFO: Matched route "login_check". {"route_parameters":{"_route":"login_check"},"request_uri":"http://ancdev.admin.aptalaska.net/~dmorphis/Portal/web/app_dev.php/Login/Verify"} []
[2015-12-18 13:55:11] security.DEBUG: Read existing security token from the session. {"key":"_security_restricted_area"} []
[2015-12-18 13:55:11] security.DEBUG: User was reloaded from a user provider. {"username":"dan.smartrg","provider":"Symfony\\Component\\Security\\Core\\User\\LdapUserProvider"} []
[2015-12-18 13:55:26] security.INFO: User has been authenticated successfully. {"username":"dan.smartrg"} []
<snip>
[2015-12-18 13:55:26] security.DEBUG: Stored the security token in the session. {"key":"_security_restricted_area"} []
<snip>
[2015-12-18 13:55:27] request.INFO: Matched route "home.index". {"route_parameters":{"_controller":"Apt\\PortalBundle\\Controller\\DefaultController::indexAction","_route":"home.index"},"request_uri":"http://ancdev.admin.aptalaska.net/~dmorphis/Portal/web/app_dev.php/"} []
[2015-12-18 13:55:28] security.DEBUG: Read existing security token from the session. {"key":"_security_restricted_area"} []
[2015-12-18 13:55:28] security.DEBUG: User was reloaded from a user provider. {"username":"dan.smartrg","provider":"Symfony\\Component\\Security\\Core\\User\\LdapUserProvider"} []
[2015-12-18 13:56:15] php.DEBUG: ldap_bind(): Unable to bind to server: Server is unwilling to perform {"type":2,"file":"/home/dmorphis/public_html/Portal/vendor/symfony/symfony/src/Symfony/Component/Ldap/LdapClient.php","line":73,"level":28928} []
[2015-12-18 13:56:15] app.ERROR: Bad credentials. [{"file":"/home/dmorphis/public_html/Portal/app/cache/dev/classes.php","line":2697,"function":"authenticate","class":"Symfony\\Component\\Security\\Core\\Authentication\\Provider\\UserAuthenticationProvide <truncated>
[2015-12-18 13:56:15] security.INFO: An AuthenticationException was thrown; redirecting to authentication entry point.
Finally I found what was the problem.
You have to chain the UserProvider
:
chain_provider:
chain:
providers: [in_memory, app_users]
in_memory:
memory: ~
app_users:
ldap:
.....</i>
这篇关于与Symfony的2.8 LDAP认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!