Platform: Add support for Postgresql pgpass file (#61517)
lib/pq has built-in support to use pgpass file for authentication when no password has been provided. However this requires that the connection does not contain the password parameter at all. Removing password parameter when postgresql password is empty in SQL store.
This commit is contained in:
1 parent
e82d437e0e
commit
b947222bf5
2 files changed
+39
-15
No files matched your search
@@ -316,15 +316,15 @@ func (ss *SQLStore) buildConnectionString() (string, error) {
|
||||
return "", fmt.Errorf("invalid host specifier '%s': %w", ss.dbCfg.Host, err)
|
||||
}
|
||||
|
||||
if ss.dbCfg.Pwd == "" {
|
||||
ss.dbCfg.Pwd = "''"
|
||||
}
|
||||
if ss.dbCfg.User == "" {
|
||||
ss.dbCfg.User = "''"
|
||||
}
|
||||
cnnstr = fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s sslcert=%s sslkey=%s sslrootcert=%s",
|
||||
ss.dbCfg.User, ss.dbCfg.Pwd, addr.Host, addr.Port, ss.dbCfg.Name, ss.dbCfg.SslMode, ss.dbCfg.ClientCertPath,
|
||||
cnnstr = fmt.Sprintf("user=%s host=%s port=%s dbname=%s sslmode=%s sslcert=%s sslkey=%s sslrootcert=%s",
|
||||
ss.dbCfg.User, addr.Host, addr.Port, ss.dbCfg.Name, ss.dbCfg.SslMode, ss.dbCfg.ClientCertPath,
|
||||
ss.dbCfg.ClientKeyPath, ss.dbCfg.CaCertPath)
|
||||
if ss.dbCfg.Pwd != "" {
|
||||
cnnstr += fmt.Sprintf(" password=%s", ss.dbCfg.Pwd)
|
||||
}
|
||||
|
||||
cnnstr += ss.buildExtraConnectionString(' ')
|
||||
case migrator.SQLite:
|
||||
|
||||
Reference in new issue
Block a user