Skip to content

Commit 1872af0

Browse files
committed
Make it clearer that the generated password is not for production use
Closes gh-30061
1 parent 2b98fce commit 1872af0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,11 @@ public InMemoryUserDetailsManager inMemoryUserDetailsManager(SecurityProperties
8282
private String getOrDeducePassword(SecurityProperties.User user, PasswordEncoder encoder) {
8383
String password = user.getPassword();
8484
if (user.isPasswordGenerated()) {
85-
logger.info(String.format("%n%nUsing generated security password: %s%n", user.getPassword()));
85+
logger.warn(String.format(
86+
"%n%nUsing generated security password: %s%n%nThis generated password is for development use only. "
87+
+ "Your security configuration must be updated before running your application in "
88+
+ "production.%n",
89+
user.getPassword()));
8690
}
8791
if (encoder != null || PASSWORD_ALGORITHM_PATTERN.matcher(password).matches()) {
8892
return password;

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/security.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ To add method-level security to a web application, you can also add `@EnableGlob
66
Additional information can be found in the {spring-security-docs}#jc-method[Spring Security Reference Guide].
77

88
The default `UserDetailsService` has a single user.
9-
The user name is `user`, and the password is random and is printed at INFO level when the application starts, as shown in the following example:
9+
The user name is `user`, and the password is random and is printed at WARN level when the application starts, as shown in the following example:
1010

1111
[indent=0]
1212
----
1313
Using generated security password: 78fa095d-3f4c-48b1-ad50-e24c31d5cf35
14+
15+
This generated password is for development use only. Your security configuration must be updated before running your application in production.
1416
----
1517

16-
NOTE: If you fine-tune your logging configuration, ensure that the `org.springframework.boot.autoconfigure.security` category is set to log `INFO`-level messages.
18+
NOTE: If you fine-tune your logging configuration, ensure that the `org.springframework.boot.autoconfigure.security` category is set to log `WARN`-level messages.
1719
Otherwise, the default password is not printed.
1820

1921
You can change the username and password by providing a `spring.security.user.name` and `spring.security.user.password`.

0 commit comments

Comments
 (0)