I am developing my first Angular project. Now I have been asked to implement LDAP security in the application. So after I followup this and this, I can see the login screen and it does also validate against AD. But the problem is I am seeing a browser authentication popup. I am not sure if it is Angular or spring security configuration issue. Any please would be great!
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);
}
}