Add support for .pgpass file (#617)

* Add support for .pgpass file
* Support password lookup in /api/connect endpoint
* Restrore removed code for BuildStringFromOptions
* Restructure connection string test and add extra case for pgpass
* Add test for FormatURL method
This commit is contained in:
Dan Sosedoff
2022-12-14 13:37:49 -06:00
committed by GitHub
parent 40474d3990
commit e0a748812d
8 changed files with 368 additions and 187 deletions

View File

@@ -142,22 +142,22 @@ func Connect(c *gin.Context) {
return
}
var sshInfo *shared.SSHInfo
url := c.Request.FormValue("url")
if url == "" {
badRequest(c, errURLRequired)
return
}
opts := command.Options{URL: url}
url, err := connection.FormatURL(opts)
url, err := connection.FormatURL(command.Options{
URL: url,
Passfile: command.Opts.Passfile,
})
if err != nil {
badRequest(c, err)
return
}
var sshInfo *shared.SSHInfo
if c.Request.FormValue("ssh") != "" {
sshInfo = parseSshInfo(c)
}