microsoft / microsoft/vscode-pgsql

Support .pgpass file for passwordless connection in corporate/CI environments

Open
#275 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
395
Forks
33
Avg merge
1h 46m
Merged PRs (30d)
3

Description

Problem

The PostgreSQL extension currently requires a password to be stored either in VS Code's secret storage (interactive only) or inline in the connection string. In corporate and CI environments, developers use a ~/.pgpass file (the standard PostgreSQL password file) to supply credentials without interactive prompts. The extension does not read .pgpass and instead always shows a password prompt or fails with authentication failed.

.pgpass format (for context)

# hostname:port:database:username:password
db.corp.example.com:5432:mydb:myuser:s3cr3t
*:5432:*:ci_runner:ci_password

File lives at ~/.pgpass (Unix) or %APPDATA%\postgresql\pgpass.conf (Windows). PostgreSQL's libpq reads it automatically, but the extension's custom connection logic bypasses it.

Steps to Reproduce

  1. Create a valid ~/.pgpass (or %APPDATA%\postgresql\pgpass.conf on Windows).
  2. In the extension, add a new connection with the matching host/port/db/user — leave password blank.
  3. Click Connect.
  4. Result: password authentication failed — extension never read .pgpass.

Expected Behaviour

Before prompting for a password, the extension should check .pgpass (standard location per OS) and use the matching entry if found. This aligns with psql/pg_dump CLI behaviour.

Proposed Implementation

  • Add a utility resolvePgpass(host, port, db, user) that reads and parses .pgpass from the OS-appropriate location.
  • Call it during connection before falling back to the password prompt.
  • Add a pgsql.pgpassFile setting to override the default path (useful for CI where .pgpass is at a non-standard location).

Environment

  • OS: Windows 11 Enterprise (path: %APPDATA%\postgresql\pgpass.conf) and Linux CI
  • VS Code: 1.89+
  • Extension: ms-ossdata.vscode-pgsql latest

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the extension's custom connection logic and the code that prompts for passwords. Trace how connection settings are resolved, then assess the proposed resolvePgpass utility and pgsql.pgpassFile override across Unix and Windows paths. Done means a matching .pgpass entry is used before prompting, with the standard locations and override behavior covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
authentication, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.