planche 0.5.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +47 -0
  2. package/dist/index.js +940 -658
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -116,6 +116,52 @@ database connections open and forwards queries with the matching driver
116
116
  `~/.ssh/known_hosts` are honoured too). A changed key refuses the
117
117
  connection until the stale entry is removed.
118
118
 
119
+ ## Gateway mode
120
+
121
+ Run one agent on a shared host so a team can use Planche with just a
122
+ browser, without anyone holding database credentials:
123
+
124
+ The web app it serves lives in its own package, so a plain `npx planche`
125
+ stays a small download; install both on the gateway host:
126
+
127
+ ```bash
128
+ npm i -g planche planche-app
129
+ planche --gateway gateway.json --addr 0.0.0.0 --allow-remote \
130
+ --token "$(openssl rand -base64 24)" --public-url https://sql.example.com
131
+ ```
132
+
133
+ (or `npx --package planche --package planche-app planche --gateway …`, or
134
+ point at your own build with `--app-dir <dir>`)
135
+
136
+ `gateway.json` lists named profiles; the credentials never leave this file:
137
+
138
+ ```json
139
+ {
140
+ "name": "Acme staging",
141
+ "profiles": [
142
+ { "name": "Shop (read-only)", "driver": "mysql", "host": "db", "port": 3306,
143
+ "user": "reporting", "password": "…", "database": "shop" },
144
+ { "name": "Shop (writable)", "readOnly": false, "driver": "postgres",
145
+ "host": "pg", "port": 5432, "user": "app", "password": "…", "database": "shop" }
146
+ ]
147
+ }
148
+ ```
149
+
150
+ - Browsers only ever send `{ "profile": "Shop (read-only)" }`; `/connect`
151
+ bodies with credentials are refused in gateway mode.
152
+ - Profiles are **read-only by default**: the agent refuses anything but a
153
+ single `SELECT` / `WITH … SELECT` / `SHOW` / `DESCRIBE` / `EXPLAIN` per
154
+ request (statement filter), and additionally puts the session in read-only
155
+ mode where the engine supports it (MySQL, PostgreSQL, SQLite). Set
156
+ `"readOnly": false` on a profile to allow writes.
157
+ - The agent serves the web app itself at `/` (`--serve-app`, on by default in
158
+ gateway mode; needs `planche-app` or `--app-dir`) so the app talks to its
159
+ own origin — the strict CSP stays
160
+ intact and no `--origin` is needed. Put a TLS reverse proxy in front and
161
+ pass its URL as `--public-url`; the printed pairing link is single-use, so
162
+ share the token (`--print-token`) with teammates and let them paste it in
163
+ the connect dialog's *Configure* box.
164
+
119
165
  ## Security
120
166
 
121
167
  - Every request except `GET /health` and `POST /pair` requires the bearer
@@ -130,6 +176,7 @@ database connections open and forwards queries with the matching driver
130
176
  machine can reach it. It speaks plain HTTP, so binding to another address
131
177
  requires `--allow-remote` plus an explicit token, and should only be done
132
178
  behind a TLS reverse proxy or an SSH port forward.
179
+ - In gateway mode credentials live only in the gateway config file on the server; browsers pick profiles by name. Read-only profiles are enforced by the agent (statement filter + engine session read-only), not by the UI.
133
180
  - The agent never stores credentials. They are passed per connection by the
134
181
  app (including SSH passwords and private key contents) and live in memory
135
182
  only while the connection is open. The only thing written to disk is the