Site icon NgDeveloper

How to disable the default spring security in spring boot ?

How to disable the default spring security in spring boot ?

To disable the spring boot’s default spring security / to disable the security for all the urls then include the below method in your custom security class which extends WebSecurityConfigurerAdapter

Method to include:

[java]
/* to permit all */
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().anyRequest().permitAll();
}

[/java]

Full class for reference:

 

[java]

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class CustomJDSecurityConfig extends WebSecurityConfigurerAdapter {

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

[/java]

 

Exit mobile version