|
| 1 | +--- |
| 2 | +'@object-ui/auth': minor |
| 3 | +--- |
| 4 | + |
| 5 | +The data lane now honors `set-auth-token`, so impersonation takes effect at all (#4467). |
| 6 | + |
| 7 | +The console injects the same localStorage bearer from two lanes: the AUTH lane |
| 8 | +(`createBearerFetch` inside `createAuthClient`) and the DATA lane |
| 9 | +(`createAuthenticatedFetch` — the adapter, `provider: 'api'` data sources, and every |
| 10 | +metadata `type: 'api'` action). better-auth's server-side bearer plugin hands a ROTATED |
| 11 | +session token back in the `set-auth-token` response header on whichever lane the call |
| 12 | +arrived over, and only the auth lane read it. A rotation issued to a data-lane call was |
| 13 | +discarded and the browser kept sending the old token. |
| 14 | + |
| 15 | +`POST /auth/admin/impersonate-user` is exactly such a call — an ordinary metadata action. |
| 16 | +The impersonated session token was dropped on the floor while the server's bearer plugin |
| 17 | +kept overwriting the impersonation cookie with the admin bearer the console kept sending, |
| 18 | +so impersonation was a complete no-op in the console rather than merely an invisible one. |
| 19 | +Support staff believed they were seeing a user's view while acting entirely as themselves. |
| 20 | + |
| 21 | +Published behaviour that moves: a data-lane response carrying `set-auth-token` now |
| 22 | +replaces the stored session token, on any API call this lane authenticated (untrusted |
| 23 | +targets remain the `sameOriginOnly` option's job — it short-circuits before any header |
| 24 | +work). The accepted cost, recorded on the card: while impersonating, the administrator's |
| 25 | +own token is replaced in localStorage for the duration, and a client that misses the stop |
| 26 | +rotation is stranded until re-login. |
| 27 | + |
| 28 | +Also in this release, all additive: |
| 29 | + |
| 30 | +- `AuthContextValue.refreshSession()` re-resolves `user`/`session` from the server in |
| 31 | + place, without raising `isLoading` — the transitions that change WHO the session is |
| 32 | + without going through `signIn`/`signOut`. |
| 33 | +- `TokenStorage.subscribeRotation()` notifies when a token already in hand is replaced by |
| 34 | + a different one. First store, `clear()`, and re-storing the same value stay silent: |
| 35 | + those transitions have an owner that updates identity itself. |
| 36 | +- `AuthClientSession.impersonatedBy?: string` — optional, set by better-auth's admin |
| 37 | + plugin for the life of an impersonated session. |
0 commit comments