Angular 4 + Spring启动+ Spring安全:获取浏览器身份验证弹出窗口

时间:2018-04-27 14:18:14

标签: spring angular spring-boot spring-security

我正在开发我的第一个Angular项目。现在我被要求在应用程序中实现LDAP安全性。因此,在我跟进thisthis后,我可以看到登录屏幕,它也会对AD进行验证。但问题是我看到了浏览器身份验证弹出窗口。我不确定它是Angular还是Spring安全配置问题。任何请你会很棒! enter image description here

WebSecurityConfiguration.java

@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
    private static final Logger log = LoggerFactory.getLogger(WebSecurityConfiguration.class);
    LdapConfiguration ldapConfig;
    ActiveProfilesConfiguration activeProfiles;
    SecurityUserConfiguration securityUser;
    SimpleAuthenticationSuccessHandler authenticationSuccessHandler;

    public WebSecurityConfiguration(LdapConfiguration ldapConfig,
                                    ActiveProfilesConfiguration activeProfiles,
                                    SecurityUserConfiguration securityUser,
                                    SimpleAuthenticationSuccessHandler authenticationSuccessHandler) {
        this.ldapConfig = ldapConfig;
        this.activeProfiles = activeProfiles;
        this.securityUser = securityUser;
        this.authenticationSuccessHandler = authenticationSuccessHandler;
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
        .httpBasic().and()
        .authorizeRequests()
      //  .antMatchers("/**").permitAll()
        .antMatchers("/index.html", "/", "/home", "/login").permitAll()
            .anyRequest().authenticated()
            .and()
        .csrf()
            .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());

app.module.ts

@Injectable()
export class XhrInterceptor implements HttpInterceptor {

  intercept(req: HttpRequest<any>, next: HttpHandler) {
    const xhr = req.clone({
      headers: req.headers.set('X-Requested-With', 'XMLHttpRequest')
    });
    return next.handle(xhr);
  }
}

0 个答案:

没有答案