You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow to specify SCRAM-SHA-256 hashes in `users.toml` instead of
plaintext passwords. Users can authenticate to pgdog without us having
to store the password anywhere.
Server auth has to be passwordless, however, e.g. RDS IAM or trust.
Copy file name to clipboardExpand all lines: .schema/users.schema.json
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -141,6 +141,13 @@
141
141
"null"
142
142
]
143
143
},
144
+
"password_hash": {
145
+
"description": "Passwords hash. Can be used to validate user logins without storing passwords in users.toml.\nServer authentication must use RDS IAM or some other passwordless authentication, e.g. trust.",
146
+
"type": [
147
+
"string",
148
+
"null"
149
+
]
150
+
},
144
151
"passwords": {
145
152
"description": "Multiple passwords for this user, all of which will be attempted during auth to server and client.",
server_password = "pgdog"# Pointless obviously, but we can test scram hash is working as expected. pgdog -> server auth is expected to be passwordless, e.g. rds iam, trust, azure working directory, etc.
Copy file name to clipboardExpand all lines: pgdog-config/src/users.rs
+61-11Lines changed: 61 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
use serde::{Deserialize,Serialize};
2
2
use std::env;
3
+
use std::fmt::Display;
3
4
use std::path::PathBuf;
4
5
use tracing::warn;
5
6
@@ -47,11 +48,11 @@ impl Users {
47
48
/// Run configuration checks.
48
49
pubfncheck(&mutself,config:&Config){
49
50
for user in&mutself.users{
50
-
if user.password().is_empty(){
51
+
if user.passwords().is_empty(){
51
52
if !config.general.passthrough_auth(){
52
53
warn!(
53
-
"user \"{}\"doesn't have a password and passthrough auth is disabled",
54
-
user.name
54
+
r#"user "{}" (database "{}") doesn't have a password and passthrough auth is disabled"#,
55
+
user.name, user.database,
55
56
);
56
57
}
57
58
@@ -64,24 +65,36 @@ impl Users {
64
65
65
66
for database in databases {
66
67
if min_pool_size > 0{
67
-
warn!("user \"{}\" (database \"{}\") doesn't have a password configured, \
68
-
so we can't connect to the server to maintain min_pool_size of {}; setting it to 0", user.name, database, min_pool_size);
68
+
warn!(
69
+
r#"user "{}" (database "{}") does not have a password configured, PgDog cannot connect to the server to maintain "min_pool_size" of {}, setting it to 0"#,
70
+
user.name, database, min_pool_size
71
+
);
69
72
user.min_pool_size = Some(0);
70
73
}
71
74
}
72
75
}
73
76
}
74
77
78
+
if user.server_password.is_none()
79
+
&& user.server_auth == ServerAuth::Password
80
+
&& user.password_hash.is_some()
81
+
{
82
+
warn!(
83
+
r#"user "{}" (database "{}") is using hash authentication but does not specify a "server_password""#,
84
+
user.name, user.database
85
+
);
86
+
}
87
+
75
88
if !user.database.is_empty() && !user.databases.is_empty(){
76
89
warn!(
77
-
r#"user "{}" is configured for both "database" and "databases", defaulting to "database""#,
78
-
user.name
90
+
r#"user "{}" is configured for both "{}" and "{:?}", defaulting to "{}""#,
/// A user entry in `users.toml`, controlling which users are allowed to connect to PgDog.
148
186
///
@@ -174,6 +212,9 @@ pub struct User {
174
212
/// Multiple passwords for this user, all of which will be attempted during auth to server and client.
175
213
#[serde(default)]
176
214
pubpasswords:Vec<String>,
215
+
/// Passwords hash. Can be used to validate user logins without storing passwords in users.toml.
216
+
/// Server authentication must use RDS IAM or some other passwordless authentication, e.g. trust.
217
+
pubpassword_hash:Option<String>,
177
218
/// Overrides [`default_pool_size`](https://docs.pgdog.dev/configuration/pgdog.toml/general/) for this user. No more than this many server connections will be open at any given time to serve requests for this connection pool.
0 commit comments