Skip to content

Commit 720768d

Browse files
author
Kevin Allioli
committed
Update docs: gb view, extras, WEBHOOK_SECRET, PORT, webhook signature
1 parent 2bc351f commit 720768d

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

docs/api.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ When `webhook_url` is set, Ghostbit sends a `POST` request on each view:
136136

137137
The request has a 5-second timeout and is fire-and-forget (failures are not retried).
138138

139+
### Webhook signature
140+
141+
If `WEBHOOK_SECRET` is configured on the server, every delivery includes an HMAC-SHA256 signature:
142+
143+
```
144+
X-Ghostbit-Signature: sha256=<hex>
145+
```
146+
147+
The signature is computed over the raw JSON body. Verify it on the receiving end:
148+
149+
```python
150+
import hmac, hashlib
151+
152+
def verify(secret: str, body: bytes, header: str) -> bool:
153+
expected = "sha256=" + hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
154+
return hmac.compare_digest(expected, header)
155+
```
156+
157+
Always use constant-time comparison to prevent timing attacks. See the [Encryption](encryption.md#webhook-signatures) page for more details and Node.js examples.
158+
139159
---
140160

141161
## Example — create and read with curl

docs/cli.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
pip install ghostbit-cli
77
```
88

9-
This installs the `gb` command.
9+
This installs the `gb` and `ghostbit` commands.
10+
11+
With optional extras for terminal rendering:
12+
13+
```bash
14+
pip install "ghostbit-cli[all]" # pygments + rich (recommended)
15+
pip install "ghostbit-cli[color]" # pygments — syntax highlighting
16+
pip install "ghostbit-cli[markdown]" # rich — Markdown rendering
17+
```
1018

1119
---
1220

@@ -63,6 +71,28 @@ Language is auto-detected from the file extension.
6371

6472
---
6573

74+
## View a paste
75+
76+
Download, decrypt, and display a paste directly in the terminal:
77+
78+
```bash
79+
# Non-password paste (key is in the URL fragment)
80+
gb view https://paste.example.com/abc123#KEY~TOKEN
81+
82+
# Password-protected paste (prompts for password interactively)
83+
gb view https://paste.example.com/abc123#~TOKEN
84+
85+
# Pipe to another tool
86+
gb view https://paste.example.com/abc123#KEY~TOKEN | less
87+
```
88+
89+
- Markdown pastes are rendered with titles, bold, lists, and code blocks (requires `rich`)
90+
- Other languages are syntax-highlighted (requires `pygments`)
91+
- Falls back to plain text if neither is installed
92+
- Burn-after-read pastes display a warning on stderr after decryption
93+
94+
---
95+
6696
## Examples
6797

6898
```bash

docs/configuration.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ All configuration is done via environment variables (or a `.env` file at the pro
88
|----------|---------|----------|-------------|
99
| `ENCRYPTION_KEY` || **Yes** | Hex-encoded 32-byte server key. Used to hash delete tokens. |
1010
| `STORAGE_BACKEND` | `sqlite` | No | `sqlite` or `redis` |
11-
| `SQLITE_PATH` | `ghostbit.db` | No | Path to the SQLite database file |
11+
| `SQLITE_PATH` | `/data/ghostbit.db` | No | Path to the SQLite database file |
1212
| `REDIS_URL` | `redis://localhost:6379` | No | Redis connection URL |
1313
| `MAX_PASTE_SIZE` | `524288` | No | Maximum paste size in bytes (default: 512 KB) |
14+
| `PORT` | `8000` | No | HTTP port the server listens on |
15+
| `WEBHOOK_SECRET` || No | If set, signs webhook deliveries with HMAC-SHA256 (`X-Ghostbit-Signature`) |
1416

1517
## Generating an encryption key
1618

@@ -53,4 +55,8 @@ ENCRYPTION_KEY=your_hex_encoded_32_byte_key_here
5355
STORAGE_BACKEND=sqlite
5456
SQLITE_PATH=/data/ghostbit.db
5557
MAX_PASTE_SIZE=524288
58+
PORT=8000
59+
60+
# Optional: sign webhook deliveries
61+
# WEBHOOK_SECRET=your_hex_encoded_secret_here
5662
```

0 commit comments

Comments
 (0)