spring-boot 中的多个身份验证提供程序不适用于 angulr js

问题描述

我有 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;

                    }

SecurityConfig.java:-

@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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...