Commit 4f49462
authored
iris: switch auth from per-RPC DB lookups to HMAC-SHA256 JWTs (#3630)
Replaces the ad-hoc bearer token auth system (every RPC does a DB hit to
hash-lookup tokens) with proper JWT-based auth using PyJWT and
HMAC-SHA256 signing.
- **`JwtTokenManager`** replaces `DbTokenVerifier`: verification is a
pure crypto check + in-memory revocation set — no database hit on the
hot path
- **`VerifiedIdentity`** dataclass carries `user_id` + `role` from JWT
claims, eliminating per-RPC role lookups from the DB
- **Login RPC** now exchanges identity tokens (GCP access tokens or raw
static config tokens) for JWTs — all auth providers converge on the same
flow
- **Signing key** persisted in new `controller_secrets` table (migration
0006) so tokens survive controller restarts
- **Dashboard** login page exchanges raw tokens for JWTs via Login RPC
before setting session cookie
- **CLI** `iris login` unified: all providers go through Login RPC
### Files changed
- `lib/iris/src/iris/rpc/auth.py` — `VerifiedIdentity`,
`_verified_identity` ContextVar, verifier protocol returns
`VerifiedIdentity`
- `lib/iris/src/iris/cluster/controller/auth.py` — `JwtTokenManager`,
`_get_or_create_signing_key`, JWT worker tokens
- `lib/iris/src/iris/cluster/controller/service.py` —
`_require_role`/`_require_admin` read from JWT claims,
Login/CreateApiKey mint JWTs
- `lib/iris/src/iris/cli/main.py` — unified login flow through Login RPC
- `lib/iris/dashboard/src/components/controller/LoginPage.vue` —
exchange tokens via Login RPC
-
`lib/iris/src/iris/cluster/controller/migrations/0006_jwt_signing_key.sql`
— `controller_secrets` table
- `lib/iris/docs/auth.md` — updated architecture docs
## Test plan
- [x] 97 unit tests pass (test_auth.py, test_api_keys.py,
test_service.py)
- [x] 1322 full iris tests pass including all e2e tests
- [x] Pre-commit (ruff, black, pyrefly) passes
- [x] E2e static auth ownership test validates JWT-based job isolation
- [x] E2e dashboard login flow validates token exchange in browser
Closes #36231 parent ec17543 commit 4f49462
File tree
14 files changed
+849
-419
lines changed- lib/iris
- dashboard/src/components/controller
- docs
- src/iris
- cli
- cluster
- controller
- migrations
- rpc
- tests
- cluster/controller
- e2e
- rpc
14 files changed
+849
-419
lines changedLines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
20 | 53 | | |
21 | 54 | | |
22 | 55 | | |
23 | | - | |
| 56 | + | |
24 | 57 | | |
25 | 58 | | |
26 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
40 | | - | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | | - | |
| 47 | + | |
44 | 48 | | |
45 | | - | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
64 | | - | |
65 | | - | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | | - | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | | - | |
74 | | - | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
85 | 97 | | |
86 | 98 | | |
87 | | - | |
| 99 | + | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
92 | | - | |
93 | | - | |
94 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
98 | 110 | | |
99 | | - | |
| 111 | + | |
100 | 112 | | |
| 113 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
230 | 229 | | |
231 | 230 | | |
232 | 231 | | |
| |||
241 | 240 | | |
242 | 241 | | |
243 | 242 | | |
244 | | - | |
| 243 | + | |
245 | 244 | | |
246 | 245 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | 246 | | |
259 | 247 | | |
260 | 248 | | |
261 | 249 | | |
262 | 250 | | |
263 | 251 | | |
264 | | - | |
265 | | - | |
| 252 | + | |
266 | 253 | | |
267 | 254 | | |
268 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
269 | 265 | | |
270 | | - | |
| 266 | + | |
271 | 267 | | |
272 | | - | |
273 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
274 | 271 | | |
275 | 272 | | |
276 | 273 | | |
| |||
0 commit comments