How it works
- Cordon listens on a local port (e.g.,
15432) - Your app connects to
localhost:15432with no password - Cordon intercepts the PostgreSQL authentication handshake
- The real password is fetched from 1Password or the OS keyring and injected
- The authenticated connection is forwarded to the upstream database
Configuration
Database connections are configured asservices in cordon.yaml, separate from HTTP routes:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Identifier for the service (used in logs) |
listen | integer | Yes | Local port to listen on |
upstream | string | Yes | Upstream database host and port |
protocol | string | Yes | Wire protocol. Currently postgres. |
auth.type | string | Yes | Auth type. Currently password. |
auth.username | string | Yes | Username to authenticate as |
auth.secret | object | Yes | Secret source reference. See Secret Sources. |
Connecting your application
Point your application at the local port instead of the upstream database:- Connection string
- Environment variable
Multiple databases
Configure multiple services for different databases, each on its own local port:PostgreSQL support requires the
pg feature. The npm package includes this by default.