Angular 4 + Spring boot + Spring Security: всплывающее окно аутентификации браузера - PullRequest
0 голосов
/ 27 апреля 2018

Я занимаюсь разработкой своего первого проекта Angular. Теперь меня попросили реализовать безопасность LDAP в приложении. Таким образом, после того, как я прослежу это и это , я вижу экран входа в систему, и он также проверяется на соответствие 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);
  }
}
...