0

Right now I configure web security adapter like -

@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.cors().and()
            .authorizeRequests()
            .anyRequest()
            .fullyAuthenticated().and()
            .httpBasic().and()
            .csrf()
            .disable();
 }
}

Which working fine and blocking all requests if not authenticated. But now I want to block all but /login. I mean, I want JUST /login and /login/* to be insecure, and rest of the app to be secured.

Anyone knows how can I achieve that?

Jahid Shohel
  • 1,395
  • 4
  • 18
  • 34

1 Answers1

0

Try to add the /login url to ignore list in WebSecurityConfigurerAdapter:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{

    @Override
    public void configure(WebSecurity webSecurity) throws Exception{
        webSecurity
            .ignoring()
                .antMatchers("/login");
    }
}
tsolakp
  • 5,858
  • 1
  • 22
  • 28