问题描述
我有 Spring Boot 应用程序,其中 db 身份验证已经到位。现在我已经添加了 LDAP 身份验证。为此,我配置了多个身份验证提供程序。 现在,如果我点击 /user 端点从浏览器登录,db 和 ldap 身份验证都在工作。 但是从 angular js 代码来看,只有 db 身份验证有效。 我的代码如下所示:
auth.js:-
authenticate : function($scope,credentials,callback) {
var headers = credentials && credentials.updatedUseremail ? {
authorization : "Basic "
+ btoa(credentials.updatedUseremail + ":"
+ credentials.password)
} : {cache:false};
$http.get('user',{
headers : headers
}).success(function(data) {
if (data.username) {
auth.authenticated = true;
}
} else {
auth.authenticated = false;
}
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
authenticationProvider.setPasswordEncoder(jasyptEncoder());
authenticationProvider.setUserDetailsService(userDetailsService);
auth.authenticationProvider(authenticationProvider);
auth.ldapAuthentication().userDetailsContextMapper(userDetailsContextMapper()).
ldapAuthoritiesPopulat or(new UserDetailsServiceLdapAuthoritiesPopulator(userDetailsService))
.userDnPatterns("uid={0},ou=people")
.userSearchBase("ou=groups")
.contextSource()
.url("ldap://localhost:8389/dc=devglan,dc=com")
.and()
.passwordCompare()
.passwordEncoder(jasyptEncoder())
.passwordAttribute("userPassword");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().
authenticationEntryPoint(failureHandler)
.and().authorizeRequests()
.antMatchers("/login").permitAll()
.anyRequest()
.authenticated()
.and().exceptionHandling().accessDeniedHandler(accessDeniedExceptionHandler)
.and()
.addFilterafter(new CsrfheaderFilter(),CsrfFilter.class)
.csrf().csrftokenRepository(csrftokenRepository());
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)