Added config generate-csrf-key, to store a CSRF key that survives restarts and works across instances
Without server.csrf.tokens.key, each server process signs CSRF tokens with a random key of its own, so tokens are lost on a restart and rejected by other instances. "job-search config generate-csrf-key" stores a new random 32-byte hex key in the configuration file, without printing it. --print only prints a key, for JOBSEARCH_SERVER_CSRF_TOKENS_KEY or another instance. An existing key is only replaced with --force, as that invalidates every issued token, and no key is stored while JOBSEARCH_SERVER_CSRF_TOKENS_KEY is set, as it would override the file.
This commit is contained in:
1 parent
18db462d89
commit
eba6af680f
7 files changed
+241
-6
No files matched your search
@@ -141,7 +141,7 @@ The `server` section is split into a number of sub-sections:
|
||||
| `server.csrf.cross_origin_protection.enabled` | bool | `true` | Reject cross-origin unsafe requests (`Sec-Fetch-Site`/`Origin`) |
|
||||
| `server.csrf.cross_origin_protection.trusted_origins` | list | | Extra origins (`https://admin.example.com`) allowed to make them, and to open WebSockets; empty: none |
|
||||
| `server.csrf.tokens.enabled` | bool | `true` | Require a signed double-submit token on unsafe requests |
|
||||
| `server.csrf.tokens.key` | string | | Hex HMAC key; empty: a random per-process key, so tokens don't survive a restart |
|
||||
| `server.csrf.tokens.key` | string | | Hex HMAC key; empty: a random per-process key, so tokens don't survive a restart. `job-search config generate-csrf-key` stores one |
|
||||
| `server.csrf.tokens.cookie_name` | string | `js_csrf` | Empty: `js_csrf` |
|
||||
| `server.csrf.tokens.header_name` | string | `X-CSRF-Token` | Empty: `X-CSRF-Token` |
|
||||
| `server.csrf.tokens.token_ttl` | duration | `12h` | `0s`: 12h |
|
||||
|
||||
Reference in new issue
Block a user