Ernesto
Ernesto

Reputation: 944

Can not switch off SecurityConfig in SpringBootApplication

I have a SecurityConfig and I authorize requests with JWT tokens. The issue is that I would like to switch off the security config for testing my websockets, because somehow I always receiving 401...

I added:

@SpringBootApplication(exclude = SecurityConfig.class)
@EnableAutoConfiguration
public class MyApp {

but it is still authoraizing the requests from websockets and basically rest also...

anyone know how to switch of security in spring, or maybe how to allow websockets messages?

regards

Upvotes: 0

Views: 39

Answers (1)

jurabek rashidov
jurabek rashidov

Reputation: 112

You should add

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

    @Configuration
    public class ApplicationSecurity extends WebSecurityConfigurerAdapter {

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

Upvotes: 3

Related Questions