简体   繁体   中英

Disable Spring Security Basic Login - Spring REST web service

In my SecurityConfig.java,

    @Override
protected void configure(AuthenticationManagerBuilder auth)
        throws Exception {
    auth.inMemoryAuthentication().withUser("user").password("password")
            .roles("USER");
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/**").hasRole("USER")
            .anyRequest().anonymous().and().httpBasic();
}

How do I totally disable Spring Security, in a way that I am able to access my web service without having to input "user" and "password"?

Use this Spring Security configuration:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().anyRequest().permitAll();
}

Make note that this does not disable in Spring Security from the request chain, it just tells Spring Security to allow all requests

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM