Browse Source

docs: add IRIS API key runbook

Explains why the key rotated (IRIS_ADM_API_KEY was commented out in
iris-web/.env), documents the fix applied 2026-03-23, and provides
step-by-step procedures for key reset, container recreation, and
diagnosis when soc-integrator returns 401/502.

Also includes full service key inventory table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tum 1 day ago
parent
commit
16e6a89dbb
1 changed files with 112 additions and 0 deletions
  1. 112 0
      docs/ops-runbook-iris-api-key.md

+ 112 - 0
docs/ops-runbook-iris-api-key.md

@@ -0,0 +1,112 @@
1
+# Runbook: IRIS Admin API Key — Keep It Static
2
+
3
+## Problem
4
+
5
+When the `iriswebapp_app` container is recreated, `post_init.py` runs on startup and sets
6
+the administrator's API key. If `IRIS_ADM_API_KEY` is **not** set in the env, it generates a
7
+**new random key** via `secrets.token_urlsafe(nbytes=64)`. This breaks the soc-integrator
8
+(HTTP 401 / 502) until the key is manually re-synced.
9
+
10
+**Root cause**: `iris-web/.env` line `IRIS_ADM_API_KEY` was commented out → random rotation
11
+on every container recreate.
12
+
13
+## Fix already applied (2026-03-23)
14
+
15
+`iris-web/.env` now has `IRIS_ADM_API_KEY` explicitly set to the current live key.
16
+`post_init.py` reads this env var and reuses it on every startup — no more rotation.
17
+
18
+---
19
+
20
+## If the key ever needs to be reset (e.g. suspected compromise)
21
+
22
+### Step 1 — Choose or generate a new key
23
+
24
+```bash
25
+python3 -c "import secrets; print(secrets.token_urlsafe(64))"
26
+```
27
+
28
+Note the output — this is `<NEW_KEY>`.
29
+
30
+### Step 2 — Update `iris-web/.env`
31
+
32
+```bash
33
+# Edit the file
34
+vi /home/tum/soc/iris-web/.env
35
+```
36
+
37
+Find and update the line:
38
+
39
+```
40
+IRIS_ADM_API_KEY=<NEW_KEY>
41
+```
42
+
43
+### Step 3 — Update soc-integrator
44
+
45
+```bash
46
+vi /home/tum/soc/soc-integrator/.env
47
+```
48
+
49
+Set:
50
+
51
+```
52
+IRIS_API_KEY=<NEW_KEY>
53
+```
54
+
55
+### Step 4 — Recreate both containers
56
+
57
+```bash
58
+# IRIS app (re-runs post_init.py with new key)
59
+cd /home/tum/soc/iris-web
60
+docker compose up -d --force-recreate app
61
+
62
+# soc-integrator (bakes new IRIS_API_KEY into container env)
63
+cd /home/tum/soc/soc-integrator
64
+docker compose up -d --force-recreate
65
+```
66
+
67
+> **Note**: `docker restart` does NOT re-read `.env` — you must use `--force-recreate`.
68
+
69
+### Step 5 — Verify
70
+
71
+```bash
72
+# 1. Confirm key in DB matches what you set
73
+docker exec iriswebapp_db psql -U postgres -d iris_db \
74
+  -c "SELECT api_key FROM \"user\" WHERE name='administrator';"
75
+
76
+# 2. End-to-end sync test
77
+cd /home/tum/soc
78
+python3 scripts/test-wazuh-iris-sync.py --no-send --minutes 60
79
+# Expected: all steps pass
80
+```
81
+
82
+---
83
+
84
+## Diagnosing a broken key (soc-integrator returning 502 / 401)
85
+
86
+```bash
87
+# Check integrator logs
88
+docker logs soc-integrator --tail=50 | grep -i "iris\|401\|502"
89
+
90
+# Read current key from IRIS DB
91
+docker exec iriswebapp_db psql -U postgres -d iris_db \
92
+  -c "SELECT api_key FROM \"user\" WHERE name='administrator';"
93
+
94
+# Compare with what soc-integrator has baked in
95
+docker exec soc-integrator env | grep IRIS_API_KEY
96
+
97
+# If they differ → follow steps 2-5 above (no need to generate a new key,
98
+# just re-sync the existing DB key into the two .env files)
99
+```
100
+
101
+---
102
+
103
+## Service key inventory (all static as of 2026-03-23)
104
+
105
+| Service | Credential | Location |
106
+|---------|-----------|----------|
107
+| IRIS admin API key | `IRIS_ADM_API_KEY` in `iris-web/.env` | Set statically; reused by `post_init.py` |
108
+| IRIS API key (integrator side) | `IRIS_API_KEY` in `soc-integrator/.env` | Must match IRIS DB value |
109
+| Wazuh API | `wazuh-wui` / password | `wazuh-docker/single-node/docker-compose.yml` env block |
110
+| Wazuh Indexer | `admin` / password | Same compose file |
111
+| Shuffle API key | `SHUFFLE_API_KEY` | `Shuffle/.env` + `soc-integrator/.env` |
112
+| Integrator internal key | `INTERNAL_API_KEY` | `soc-integrator/.env` |