I added one custom Security Config in my application on Spring Boot, but the message about \"Using default security password\" is still there in LOG file.
Is there a
Look up: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-security.html
From AuthenticationManagerConfiguration.java looking at code, I see below. Also the in-memory configuration is a fallback if no authentication manager is provided as per Javadoc. Your earlier attempt of Injecting the Authentication Manager would work because you will no longer be using the In-memory authentication and this class will be out of picture.
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
if (auth.isConfigured()) {
return;
}
User user = this.securityProperties.getUser();
if (user.isDefaultPassword()) {
logger.info("\n\nUsing default security password: " + user.getPassword()
+ "\n");
}
Set<String> roles = new LinkedHashSet<String>(user.getRole());
withUser(user.getName()).password(user.getPassword()).roles(
roles.toArray(new String[roles.size()]));
setField(auth, "defaultUserDetailsService", getUserDetailsService());
super.configure(auth);
}
If you use inmemory authentication which is default, customize your logger configuration for org.springframework.boot.autoconfigure.security.AuthenticationManagerConfiguration and remove this message.
On spring boot 2 with webflux you need to define a ReactiveAuthenticationManager
I came across the same problem and adding this line to my application.properties solved the issue.
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration
It's one of the Spring's Automatic stuffs which you exclude it like excluding other stuffs such as actuators. I recommend looking at this link
Adding following in application.properties
worked for me,
security.basic.enabled=false
Remember to restart the application and check in the console.
It is also possible to just turn off logging for that specific class in properties :
logging.level.org.springframework.boot.autoconfigure.security.AuthenticationManagerConfiguration=WARN
For Reactive Stack (Spring Webflux, Netty) you either need to exclude ReactiveUserDetailsServiceAutoConfiguration.class
@SpringBootApplication(exclude = {ReactiveUserDetailsServiceAutoConfiguration.class})
Or define ReactiveAuthenticationManager bean (there are different implementations, here is the JWT one example)
@Bean
public ReactiveJwtDecoder jwtDecoder() {
return new NimbusReactiveJwtDecoder(keySourceUrl);
}
@Bean
public ReactiveAuthenticationManager authenticationManager() {
return new JwtReactiveAuthenticationManager(jwtDecoder());
}