apollo icon indicating copy to clipboard operation
apollo copied to clipboard

使用LDAP 启动报springSecurityFilterChain BeanInstantiationException

Open poweryang1990 opened this issue 8 years ago • 7 comments

我在使用LDAP进行身份验证的时候启动报错 org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.NullPointerException 但是在使用Auth的时候没有报错,我对比了WebSecurityConfigurerAdapter ,configure方法的也没有什么区别,但是LDAP模式下 启动时断点无法进入configure方法,不知道是哪里的问题

麻烦大神帮忙看一下

poweryang1990 avatar Oct 22 '18 11:10 poweryang1990

能否根据错误堆栈,看下具体报错的代码?我这里没有ldap环境,所以不太好重现问题,是否有比较简单的方法搭建本地ldap环境?

nobodyiam avatar Oct 22 '18 13:10 nobodyiam

嗯 在看看 我是直接用的 公司 Windows AD,你尝试可以用 OpenLdap搭建一个

poweryang1990 avatar Oct 23 '18 02:10 poweryang1990

我可以测试。只是没调试通过,LDAP 的配置是加在portal项目的 application.yml 中吗?能否给一个已测试可以的配置的例子。

laraok avatar Oct 23 '18 05:10 laraok

貌似是缺少了配置userDnPatterns,我本地是这么测试的,新建一个application-ldap.yml,然后配置

spring:
  ldap:
    base: "dc=example,dc=org"
    username: "cn=admin,dc=example,dc=org"
    password: "admin"
    userDnPatterns: "uid={0}"
    urls:
    - "ldap://localhost:389"

启动是不报错了,不过估计userDnPatterns配的不对,所以后续验证用户名和密码还是不行。

后续1.2.0版本我们会使用另一种方式来接入ldap,可以参考 #1562

nobodyiam avatar Oct 28 '18 06:10 nobodyiam

多谢, #1562 这个PR的分支 我在本地用过 亲测可用的,但是在用户筛选的时候 无法筛选出域里的账户 进行授权配置。我觉得应该是需要在域账户登录完后 将数据同步到Apollo数据库用户表里

poweryang1990 avatar Oct 29 '18 03:10 poweryang1990

@poweryang1990

我本地测试是可以选择用户的,比如在创建项目、namespace授权等页面,这块配置是和ldap.mapping相关的,你看看配置是否正确?

ldap:
  mapping: # 配置 ldap 属性
    objectClass: "inetOrgPerson" # ldap 用户 objectClass 配置
    loginId: "uid" # ldap 用户惟一 id,用来作为登录的 id
    userDisplayName: "cn" # ldap 用户名,用来作为显示名
    email: "mail" # ldap 邮箱属性

nobodyiam avatar Oct 29 '18 05:10 nobodyiam

1.2.0版本已经发布,增加了增加Active Directory接入方式,同时重构ldap支持,无需改动代码即可接入ldap登录。

nobodyiam avatar Dec 10 '18 15:12 nobodyiam