0

I have implemented a Rest api using spring and used Spring security for securing the api, my security config code is :

http
     .authorizeRequests()
     .anyRequest().authenticated()
     .and()
     .requestCache()
     .requestCache(new NullRequestCache())
     .and()
     .httpBasic();

this code will authenticate all the urls but I want to permit a specific url for anonymous users to sign-up in my application so I did change the security config to below code :

http
     .authorizeRequests()
     .antMatchers("/signup").permitAll()
     .antMatchers("/**").authenticated()
     .and()
     .requestCache()
     .requestCache(new NullRequestCache())
     .and()
     .httpBasic();

but I still needs to be authenticated to access the /signup request call. How can I permit just some request calls in my api?

1 Answers1

2

I should Override configure method with WebSecurity parameter and use the following code to ignore the /signup request.

@Override
public void configure(WebSecurity web) throws Exception {
    super.configure(web);
    web.ignoring().antMatchers("/signup");
}