diff options
| author | bndw <ben@bdw.to> | 2026-02-14 10:02:52 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 10:02:52 -0800 |
| commit | 5d21632ea70e1c7de7becb7ab6227b06b1535a83 (patch) | |
| tree | e63bcbe8cdf7dc888ca0e3476ad529690a0a44a8 /internal/auth/README.md | |
| parent | d30459513ec44ab298fafd1bfe0edc08d6ab62e4 (diff) | |
feat: add separate read/write allowlists for granular access control
- Split allowed_npubs into allowed_npubs_read and allowed_npubs_write
- Write operations: Publish, Delete, Create, Update, Insert, Remove, Set, Put
- Read operations: everything else (Query, Subscribe, Get, List, etc.)
- Auth interceptor checks appropriate list based on method type
- Enables common patterns:
- Public relay: only some can write, everyone can read
- Private relay: restricted read and write
- Open relay: everyone can read and write
- Updated config, docs, and comprehensive tests
Use cases: "only some can write, everyone can read"
Diffstat (limited to 'internal/auth/README.md')
| -rw-r--r-- | internal/auth/README.md | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/auth/README.md b/internal/auth/README.md index df0de6a..366e110 100644 --- a/internal/auth/README.md +++ b/internal/auth/README.md | |||
| @@ -209,9 +209,20 @@ authOpts := &auth.InterceptorOptions{ | |||
| 209 | - **`TimestampWindow`**: Maximum age of events in seconds (default: 60) | 209 | - **`TimestampWindow`**: Maximum age of events in seconds (default: 60) |
| 210 | - **`Required`**: Whether to reject unauthenticated requests (default: false) | 210 | - **`Required`**: Whether to reject unauthenticated requests (default: false) |
| 211 | - **`ValidatePayload`**: Whether to verify payload hash when present (default: false) | 211 | - **`ValidatePayload`**: Whether to verify payload hash when present (default: false) |
| 212 | - **`AllowedNpubs`**: Optional whitelist of allowed pubkeys (nil = allow all) | 212 | - **`AllowedNpubsRead`**: Optional whitelist of allowed pubkeys for read operations (nil = allow all) |
| 213 | - Config accepts npub format only (human-readable bech32) | 213 | - Config accepts npub format only (human-readable bech32) |
| 214 | - Automatically normalized to hex format (computer-readable) at config load time | 214 | - Automatically normalized to hex format (computer-readable) at config load time |
| 215 | - Controls access to Query, Get, List, Subscribe, and other read methods | ||
| 216 | - **`AllowedNpubsWrite`**: Optional whitelist of allowed pubkeys for write operations (nil = allow all) | ||
| 217 | - Config accepts npub format only (human-readable bech32) | ||
| 218 | - Automatically normalized to hex format (computer-readable) at config load time | ||
| 219 | - Controls access to Publish, Delete, Create, Update, and other write methods | ||
| 220 | |||
| 221 | **Access Control Patterns:** | ||
| 222 | - **Public relay**: Set `AllowedNpubsWrite` (only some can publish), leave `AllowedNpubsRead` empty (everyone can read) | ||
| 223 | - **Private relay**: Set both lists (restricted read and write access) | ||
| 224 | - **Open relay**: Leave both empty (everyone can read and write) | ||
| 225 | - **Read-only relay**: Set `AllowedNpubsRead`, block all writes | ||
| 215 | 226 | ||
| 216 | ### NostrCredentials Options | 227 | ### NostrCredentials Options |
| 217 | 228 | ||
