File tree Expand file tree Collapse file tree
pgdog/src/frontend/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,3 +91,34 @@ async fn test_passthrough_auth() {
9191 user. execute ( "SELECT 1" ) . await . unwrap ( ) ;
9292 original. execute ( "SELECT 1" ) . await . unwrap ( ) ;
9393}
94+
95+ #[ tokio:: test]
96+ #[ serial]
97+ async fn test_user_without_password_passthrough_auth ( ) {
98+ let admin = admin_sqlx ( ) . await ;
99+
100+ admin. execute ( "RELOAD" ) . await . unwrap ( ) ;
101+ admin. execute ( "SET auth_type TO 'scram'" ) . await . unwrap ( ) ;
102+ assert_setting_str ( "auth_type" , "scram" ) . await ;
103+
104+ let user = "postgres://pgdog2:pgdog@127.0.0.1:6432/pgdog" ;
105+
106+ let no_password_err = PgConnection :: connect ( user) . await . err ( ) . unwrap ( ) ;
107+
108+ assert ! (
109+ no_password_err
110+ . to_string( )
111+ . contains( "password for user \" pgdog2\" and database \" pgdog\" is wrong" )
112+ ) ;
113+
114+ admin
115+ . execute ( "SET passthrough_auth TO 'enabled_plain'" )
116+ . await
117+ . unwrap ( ) ;
118+ assert_setting_str ( "passthrough_auth" , "enabled_plain" ) . await ;
119+
120+ let mut user = PgConnection :: connect ( user) . await . unwrap ( ) ;
121+
122+ user. execute ( "SELECT 1" ) . await . unwrap ( ) ;
123+ user. close ( ) . await . unwrap ( ) ;
124+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ name = "pgdog"
33database = " pgdog"
44password = " pgdog"
55
6+ [[users ]]
7+ name = " pgdog2"
8+ database = " pgdog"
9+
610[[users ]]
711name = " pgdog_session"
812database = " pgdog"
Original file line number Diff line number Diff line change @@ -250,8 +250,7 @@ impl Client {
250250 stream. send ( & Authentication :: Ok ) . await ?;
251251 }
252252
253- // Allow pools to connect if passthrough password exists
254- if passthrough_password. is_some ( ) {
253+ if passthrough_password. is_some ( ) && conn. cluster ( ) ?. password ( ) . is_empty ( ) {
255254 conn. resume_cluster_pools ( ) ;
256255 }
257256
You can’t perform that action at this time.
0 commit comments