I want to disable spring security in my app and I set the property security.basic.enable=false in the application.yml file.
security:
basic:
enabled: false
And I checked the /env using spring-boot-actuator and find it's loaded correctly:(at line 2)
[classpath:/application.yml]":{"spring.datasource.url":"jdbc:mysql://localhost:3306/toe?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true","spring.datasource.username":"root","spring.datasource.password":"******",
"security.basic.enabled":false,
"server.port":7777,"flyway.enabled":false}}
However,the security configuration is still work, I can't access the ones need authenticated, but I can access those are permitAll.
This is the application class:
@SpringBootApplication
@MapperScan("team.xuli.toe.dao")
public class ToeServerApplication {
public static void main(String[] args) {
SpringApplication.run(ToeServerApplication.class, args);}
}
This is the securityConfigutaion:
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.httpBasic();
http.
authorizeRequests()
.antMatchers("/hello").permitAll()
.anyRequest().authenticated();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
System.out.println("user added in mem!");
auth
.inMemoryAuthentication()
.withUser("xqf").password("123").roles("ADMIN");
}
}