Repository navigation
Commit bf71ccb
Enforce panel_admin for ingress sessions (#7308)
* Enforce panel_admin for ingress sessions
Core allows non-admin users to create ingress sessions and read add-on info
for any app slug, since the frontend needs both to open apps that set
panel_admin: false. The Supervisor ingress proxy only validated the session
cookie, so a non-admin user could open the ingress UI of any app, including
admin-only ones such as the Terminal or VS Code app.
Resolve the user's role in Supervisor from the Core user record that session
creation already fetches: a user is admin when they are the owner or an
active member of the system-admin group, mirroring Core's definition. The
role is cached on the session and the ingress proxy returns 403 when a
non-admin session targets an app with panel_admin set. This protects every
installation as soon as Supervisor updates, independent of the Core version.
A user ID is now required to create a session, which Core has sent since
2023.9. Sessions without user data are dropped on load. Cached roles are
cleared on load and resolved again on first use, so sessions that survive a
restart pick up role changes. While Core is unreachable a session is treated
as non-admin for that request without caching the result.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Refresh the ingress session user on resolve and drop removed users
The user name and username stored with an ingress session were looked up
once at creation and forwarded to the app unchanged for the lifetime of the
session, so a renamed user kept sending the old name and a removed user kept
sending their identity.
When a session is resolved on first use, store the fresh user record along
with the role instead of only the admin flag. Invalidate the session when
the user no longer exists, and reject session creation for a user ID Core
does not know.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Invalidate ingress sessions of deactivated users
A deactivated user cannot log in to Core anymore, but an existing ingress
session kept working for apps without an admin-only panel. Treat inactive
users like removed ones: reject session creation and invalidate the session
when it is resolved.
Also parametrize the user list mock explicitly in the tests instead of
branching on the parameter type.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Cache the ingress role per user instead of per session
The admin role is runtime state derived from Core, not part of the
session. Storing it on the session added a field to the on-disk session
format that was written on unload only to be dropped again on load, and
used None on the session data to mark unresolved sessions.
Keep the role in an in-memory dict keyed by user ID on the Ingress
manager instead. The session format is unchanged, and a restart starts
with an empty cache so roles are resolved again on first use. The cache
only ever receives IDs of users Core knows, since session creation
rejects unknown users and resolving drops their sessions, so it is
bounded by the user list.
All sessions of a user share the entry and every new session refreshes
it, so a demoted user's older sessions lose admin access as soon as the
user creates a new session instead of only after a restart or expiry.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Cache the ingress user record instead of only the role
A session created while Core was unreachable only stores the user ID.
Once the user's role got cached through another session, the handler no
longer resolved that session, so the app never received the user name
headers for it.
Cache the whole user record per user ID instead and build the forwarded
headers from it. All sessions of a user then share one up-to-date name,
and the record stored with the session is only the fallback while Core
is unreachable, so it no longer needs to be rewritten on resolve.
Also split the admin check so the denial log names the user.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>1 parent 44f16a5 commit bf71ccb
5 files changed
Lines changed: 504 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 117 | + | |
| 118 | + | |
120 | 119 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
127 | 130 | | |
128 | | - | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
157 | 168 | | |
158 | 169 | | |
159 | 170 | | |
160 | | - | |
| 171 | + | |
161 | 172 | | |
162 | 173 | | |
163 | | - | |
| 174 | + | |
164 | 175 | | |
165 | 176 | | |
166 | 177 | | |
| |||
172 | 183 | | |
173 | 184 | | |
174 | 185 | | |
175 | | - | |
| 186 | + | |
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
| |||
198 | 209 | | |
199 | 210 | | |
200 | 211 | | |
201 | | - | |
| 212 | + | |
202 | 213 | | |
203 | 214 | | |
204 | 215 | | |
| |||
238 | 249 | | |
239 | 250 | | |
240 | 251 | | |
241 | | - | |
| 252 | + | |
242 | 253 | | |
243 | 254 | | |
244 | 255 | | |
245 | | - | |
| 256 | + | |
246 | 257 | | |
247 | 258 | | |
248 | 259 | | |
| |||
320 | 331 | | |
321 | 332 | | |
322 | 333 | | |
323 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
324 | 353 | | |
325 | | - | |
| 354 | + | |
326 | 355 | | |
327 | 356 | | |
328 | | - | |
| 357 | + | |
329 | 358 | | |
330 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
331 | 368 | | |
332 | 369 | | |
333 | 370 | | |
334 | | - | |
| 371 | + | |
335 | 372 | | |
336 | 373 | | |
337 | 374 | | |
338 | 375 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
345 | 382 | | |
346 | 383 | | |
347 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
612 | 615 | | |
613 | 616 | | |
614 | 617 | | |
| |||
627 | 630 | | |
628 | 631 | | |
629 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
630 | 640 | | |
631 | 641 | | |
632 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
108 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
109 | 116 | | |
110 | | - | |
111 | | - | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
139 | 150 | | |
140 | 151 | | |
141 | 152 | | |
| |||
0 commit comments