Remove “Using default security password” on Spring Boot

后端 未结 18 2192
小鲜肉
小鲜肉 2020-12-04 12:13

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

18条回答
  •  暖寄归人
    2020-12-04 12:23

    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 roles = new LinkedHashSet(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.

提交回复
热议问题