DefaultLdapAuthoritiesPopulatorは検索スコープを "ONE_LEVEL"に設定しますが、ユーザーが所属するグループのリストを取得するには "SUBSCOPE"を検索する必要があります。設定でLdapAuthoritiesPopulatorをカスタマイズする
私は「設定」スタイルのスプリング設定(コードではなくXML)に従っています。カスタムLdapAuthoritiesPopulatorをXMLで設定する方法の例がたくさんありますが、コードでそれを行う方法に固執しています。ここで
は、私がこれまで持っているものです。
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.contextSource().url("ldap://ldap.company.org/")
.and()
.userSearchBase("o=company.org,c=us")
.userSearchFilter("(uid={0})")
.groupSearchBase("o=company.org,c=us")
.groupSearchFilter("(&(objectClass=groupOfUniqueNames)(uniqueMember={0}))");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().and().authorizeRequests()
.antMatchers("/api/**").authenticated()
.anyRequest().permitAll();
}
}
欠けている私はDefaultLdapAuthoritiesPopulatorに検索範囲を設定できるようにする必要があるということです。クラス自体は "setSearchSubtree"メソッドを公開しますが、LdapAuthenticationProviderConfigurerはそれを設定する方法を提供しません。
提案がありますか?あなたの検索を開始する前に
final SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
:
ソリューションを見つけましたか? – Saita