Repository navigation
Commit 4ea75df
authored
feat(admin): event views show which administrator made each change, and why (#442)
Builds on #438 (#258), now merged.
An administrator couldn't read why a change was made, or which
administrator made it. The dashboard's events said "by an
administrator", and `audit list` printed only the account's ID. A
recovery's justification was stored with the event, but no view showed
it.
Now the dashboard and `audit list` show who made each change and why,
with where the request came from.
Closes #260. Part of #379.
## How
- **The shared view.** `sourceorigin_common::admin::Event` gains:
- `administrator`: the acting administrator's current handle, looked up
once per administrator on each page;
- `reason`, `ip` and `device`;
- `erased`, set once retention or a purge deleted them.
`AdminService::events` fills them, so the dashboard, `audit list` and
its `--output json` read the same data.
- **Dashboard.** An event caused by an administrator reads "by @alice:
“Lost every passkey”", with the handle linking their account. The device
("Chrome on Linux", as the owner's history words it) and IP address
follow, or "personal data erased". The Events page, an account's recent
events and the overview share this renderer. Known kinds were already
described in words. An `AccountDisabled` event recorded before #258
still shows the reason from its own field.
- **`audit list`.** It prints `admin @alice` and a REASON column.
`--output json` adds the origin.
- **Docs.** `surfaces.md` and `administration.md` say what event views
show.
## Proof
- `recoveries_are_started_and_undone_from_the_dashboard`: an
administrator starts a recovery. The recovery's row on the account page
links `@handle` and quotes the reason. The service's view carries the
handle, the reason and the IP address.
- `audit_list_names_the_administrator_and_their_reason`: `audit list`'s
line names `admin @alice` and ends with the reason.
- On a preview, an administrator disabled and re-enabled an account,
each with a reason. The dashboard showed "by @ev-admin-…: “Appeal
accepted” · device Chrome on Linux · IP …", and `audit list` printed
`admin @ev-admin-…` with each reason.
- Dashboard, CLI and admin tests pass, and so do clippy and `just docs`.
Reviewed by GPT 6.1 Sol. It found no correctness or privacy issues:
administrators could already read IP addresses and devices in an
account's security history. Its two findings are fixed:
- The test matched the sidebar's handle and never checked `audit list`.
- A purged administrator's handle was looked up once per event.
> [!NOTE]
> Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol
(via T3 Code)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Admin event views
- Extended the shared admin `Event` model with an optional administrator
handle, reason, request IP, device, and an erasure flag.
- Updated event retrieval to include stored reason and request origin.
It resolves each administrator’s current handle once per page. If the
account no longer exists, the handle is omitted.
- Updated the dashboard event list to show the administrator’s handle,
the recorded reason, and available device and IP details. If personal
data was erased, it displays that status instead of request details.
- Updated `audit list` to include a `REASON` column. It shows `erased`
when the reason has been erased and includes administrator handles when
available. JSON output uses the expanded shared event view.
## Reasons for administrative changes
- Made a `Reason` required for administrative mutations across accounts,
sessions, invitations, administrator access, clients, keys, handles,
deliveries, audit pruning, and related operations.
- Updated dashboard forms and CLI commands to collect and pass reasons
to the service layer. Alert updates now require a note that serves as
the reason.
- Recorded change reasons in events. Reasons for account changes also
appear in the affected owner’s security history. Announcements use the
fixed reason “See message contents.”
- Separated read-event context from change-event context. Reads use
`Operator::reading()` without a reason; changes use
`Operator::context(reason)`.
## Tests and documentation
- Updated service, CLI, dashboard, and browser tests for required
reasons and the expanded event views. Added checks for administrator
identity and reasons in recovery and audit-list output.
- Updated administration guides, CLI references, runbooks, and
operational examples to include required reason arguments and describe
event-view details.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 1019072 commit 4ea75df
10 files changed
Lines changed: 199 additions & 33 deletions
File tree
- apps/auth-service/src
- admin/service
- cli
- web/admin
- crates
- common/src
- ui/src
- admin
- settings
- docs/dev
- architecture
- operations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
43 | 53 | | |
44 | 54 | | |
45 | 55 | | |
46 | 56 | | |
| 57 | + | |
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
50 | 65 | | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
56 | 89 | | |
57 | 90 | | |
58 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
| 179 | + | |
179 | 180 | | |
180 | | - | |
| 181 | + | |
181 | 182 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 183 | + | |
192 | 184 | | |
193 | 185 | | |
194 | 186 | | |
195 | 187 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
200 | 212 | | |
201 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
202 | 217 | | |
203 | 218 | | |
204 | 219 | | |
205 | 220 | | |
206 | 221 | | |
207 | | - | |
| 222 | + | |
208 | 223 | | |
209 | 224 | | |
210 | 225 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
457 | 458 | | |
458 | 459 | | |
459 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
460 | 490 | | |
461 | 491 | | |
462 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
966 | 967 | | |
967 | 968 | | |
968 | 969 | | |
969 | | - | |
| 970 | + | |
| 971 | + | |
970 | 972 | | |
971 | 973 | | |
972 | 974 | | |
| |||
992 | 994 | | |
993 | 995 | | |
994 | 996 | | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
995 | 1029 | | |
996 | 1030 | | |
997 | 1031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
378 | 380 | | |
379 | 381 | | |
380 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
| |||
390 | 396 | | |
391 | 397 | | |
392 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
393 | 413 | | |
394 | 414 | | |
395 | 415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
| 93 | + | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
96 | 104 | | |
97 | 105 | | |
98 | 106 | | |
| |||
109 | 117 | | |
110 | 118 | | |
111 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
112 | 134 | | |
113 | 135 | | |
114 | 136 | | |
| |||
274 | 296 | | |
275 | 297 | | |
276 | 298 | | |
277 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
278 | 302 | | |
279 | 303 | | |
| 304 | + | |
280 | 305 | | |
281 | 306 | | |
282 | 307 | | |
| |||
551 | 576 | | |
552 | 577 | | |
553 | 578 | | |
| 579 | + | |
554 | 580 | | |
555 | 581 | | |
556 | 582 | | |
| |||
563 | 589 | | |
564 | 590 | | |
565 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
566 | 595 | | |
567 | 596 | | |
568 | 597 | | |
569 | 598 | | |
570 | | - | |
| 599 | + | |
571 | 600 | | |
572 | 601 | | |
573 | 602 | | |
| |||
0 commit comments