Commit 14378e9
committed
fix: set IUserSession user after bearer token validation
Signed-off-by: Han Gerrits <han@gerrits.net>
fix: set IUserSession user after bearer token validation" --body "## Summary
When user_oidc validates a bearer token in Backend::getCurrentUserId(), it returns the correct userId but does not call IUserSession::setUser().
This leaves the user session in an inconsistent state where getCurrentUserId() succeeds but DI-injected \$userId parameters remain null.
## Problem
OCS controllers and CalDAV plugins that receive \$userId via dependency injection get null instead of the authenticated user's ID when the request
is authenticated via OIDC bearer token. This causes:
- **Deck**: TypeError: ...\$userId must be of type string, null given
- **Talk**: Same TypeError pattern
- **Tasks** (CalDAV): 500 errors from null userId
These apps work correctly with session-based OIDC login (where setUser() IS called) but fail with bearer token authentication.
## Fix
Call IUserSession::setUser() after successful bearer token validation at all three return points in getCurrentUserId(). IUserSession is resolved via
Server::get() rather than constructor injection to avoid a circular dependency.
## Testing
1. Configure an OIDC provider with bearer token validation enabled
2. Make API requests to Deck, Talk, or CalDAV endpoints using a bearer token
3. Verify 200 responses instead of 500 errors"1 parent b26e927 commit 14378e9
1 file changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
| 343 | + | |
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
| 348 | + | |
346 | 349 | | |
347 | 350 | | |
348 | 351 | | |
| |||
364 | 367 | | |
365 | 368 | | |
366 | 369 | | |
| 370 | + | |
367 | 371 | | |
368 | 372 | | |
369 | 373 | | |
| |||
375 | 379 | | |
376 | 380 | | |
377 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
378 | 402 | | |
379 | 403 | | |
380 | 404 | | |
| |||
0 commit comments