-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Add support for Postgres trust host auth method with Docker Compose #41511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Postgres trust host auth method with Docker Compose #41511
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @theodorosidmar. I've left a few comments for your consideration.
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD")); | ||
Assert.state(StringUtils.hasLength(password), "PostgreSQL password must be provided"); | ||
return password; | ||
} | ||
|
||
private Boolean hasTrustAuthMethod(Map<String, String> env) { | ||
String postgresAuthMethod = env.getOrDefault("POSTGRES_HOST_AUTH_METHOD", "password"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a default is needed here so this could just use get
.
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD")); | ||
Assert.state(StringUtils.hasLength(password), "PostgreSQL password must be provided"); | ||
return password; | ||
} | ||
|
||
private Boolean hasTrustAuthMethod(Map<String, String> env) { | ||
String postgresAuthMethod = env.getOrDefault("POSTGRES_HOST_AUTH_METHOD", "password"); | ||
return Objects.equals(postgresAuthMethod, "trust"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't really use Objects.equals
. This could be return "trust".equals(postgresAuthMethod);
instead.
@@ -78,6 +78,12 @@ void getPasswordWhenHasPostgresqlPassword() { | |||
assertThat(environment.getPassword()).isEqualTo("secret"); | |||
} | |||
|
|||
@Test | |||
void getPasswordWhenHasTrustAuthMethod() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPasswordWhenHasTrustHostAuthMethod()
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD")); | ||
Assert.state(StringUtils.hasLength(password), "PostgreSQL password must be provided"); | ||
return password; | ||
} | ||
|
||
private Boolean hasTrustAuthMethod(Map<String, String> env) { | ||
String postgresAuthMethod = env.getOrDefault("POSTGRES_HOST_AUTH_METHOD", "password"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, I'd rename postgresAuthMethod
to hostAuthMethod
.
a0000fd
to
8e9a482
Compare
Awesome. Thank you for the review. Here you go: 8e9a482 |
Thanks very much, @theodorosidmar, and congratulations on making your first contribution to Spring Boot. |
I should be thanking you. Thank you for your attention. Glad to contribute. |
@wilkinsona can this PR be backported to 3.3.x? |
I'm afraid not. We don't backport enhancements to maintenance branches. |
Fixes #41509