Commit 67feb73
committed
refactor(speaker): scope a request by the tenant it declares, not by an id prefix
A speaker id was minted as `user_{tenant}_...` in three unrelated places, and
the WebUI treated that prefix as access control:
const userPrefix = `user_${user.id}_`
if (!speakerId.startsWith(userPrefix)) {
alert('You can only delete your own speakers.')
Deciding permission by string-matching a naming convention only holds while the
convention does. It already did not: moving the tenant to Chronicle's user id
left all 51 live speakers with ids reading `user_1_` and an owner of
`69b80e5894aa9ec334a421c9`, so the Speakers page filtered its own gallery down
to nothing and every delete was refused.
Ids are now opaque (`speaker_{uuid}`) and ownership is only ever
`speakers.user_id`. The three by-id endpoints plus `/enroll/append` take the
tenant the caller is acting for and 404 on a mismatch — 404 rather than 403 so
a refusal does not confirm the speaker exists. The service still has no caller
authentication, so this bounds mistakes, not attackers; the WebUI's alert
claimed a guarantee that was never enforced anywhere.
Existing ids keep their prefix. It is inert now, and renaming them would have
to move on-disk enrollment/quarantine directories, relative paths stored in
`speaker_audio_segments`, per-speaker manifests, and denormalized copies in
four Mongo collections plus `User.wakeword_allowed_speakers` — where a missed
rewrite silently disables the wake-word gate rather than failing.
The WebUI can no longer mint a tenant from a typed username: this service
cannot invent a Chronicle user id, so the selector only picks among tenants
that already have speaker data.1 parent d1b4fb8 commit 67feb73
25 files changed
Lines changed: 214 additions & 241 deletions
File tree
- backends/advanced/src/advanced_omi_backend
- controllers
- routers/modules
- workers
- extras
- ml-experiments/experiments/pyannote_diarization_validation
- speaker-recognition
- scripts
- src/simple_speaker_recognition/api
- core
- routers
- tests
- webui/src
- components
- contexts
- hooks
- pages
- services
- utils
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
693 | | - | |
| 693 | + | |
694 | 694 | | |
695 | 695 | | |
696 | 696 | | |
| |||
954 | 954 | | |
955 | 955 | | |
956 | 956 | | |
957 | | - | |
| 957 | + | |
958 | 958 | | |
959 | 959 | | |
960 | 960 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
458 | 460 | | |
459 | 461 | | |
460 | 462 | | |
| |||
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1511 | 1511 | | |
1512 | 1512 | | |
1513 | 1513 | | |
1514 | | - | |
1515 | | - | |
| 1514 | + | |
| 1515 | + | |
1516 | 1516 | | |
1517 | 1517 | | |
1518 | 1518 | | |
| |||
1558 | 1558 | | |
1559 | 1559 | | |
1560 | 1560 | | |
1561 | | - | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
1562 | 1564 | | |
1563 | 1565 | | |
1564 | 1566 | | |
1565 | 1567 | | |
1566 | 1568 | | |
1567 | 1569 | | |
| 1570 | + | |
1568 | 1571 | | |
1569 | 1572 | | |
1570 | 1573 | | |
1571 | 1574 | | |
1572 | 1575 | | |
1573 | 1576 | | |
1574 | 1577 | | |
| 1578 | + | |
| 1579 | + | |
1575 | 1580 | | |
1576 | 1581 | | |
1577 | 1582 | | |
| |||
1585 | 1590 | | |
1586 | 1591 | | |
1587 | 1592 | | |
| 1593 | + | |
1588 | 1594 | | |
1589 | 1595 | | |
1590 | 1596 | | |
| |||
1731 | 1737 | | |
1732 | 1738 | | |
1733 | 1739 | | |
1734 | | - | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
1735 | 1743 | | |
1736 | 1744 | | |
1737 | 1745 | | |
| 1746 | + | |
| 1747 | + | |
1738 | 1748 | | |
1739 | 1749 | | |
1740 | 1750 | | |
1741 | 1751 | | |
1742 | | - | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1743 | 1756 | | |
1744 | 1757 | | |
1745 | 1758 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
421 | | - | |
| 423 | + | |
422 | 424 | | |
423 | 425 | | |
424 | 426 | | |
| |||
584 | 586 | | |
585 | 587 | | |
586 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
587 | 592 | | |
588 | 593 | | |
589 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
292 | 294 | | |
293 | 295 | | |
294 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
295 | 299 | | |
296 | 300 | | |
297 | 301 | | |
| |||
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
331 | | - | |
| 335 | + | |
| 336 | + | |
332 | 337 | | |
333 | 338 | | |
334 | 339 | | |
| |||
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
360 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
361 | 369 | | |
362 | 370 | | |
363 | 371 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
Lines changed: 21 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
121 | 112 | | |
122 | 113 | | |
123 | 114 | | |
| |||
135 | 126 | | |
136 | 127 | | |
137 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
138 | 147 | | |
139 | 148 | | |
140 | 149 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| 541 | + | |
541 | 542 | | |
542 | 543 | | |
543 | 544 | | |
544 | | - | |
545 | | - | |
| 545 | + | |
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| |||
0 commit comments