Remove admin token from sessionStorage during impersonation

Embed admin_id claim in impersonation JWTs and add a backend
/api/admin/unimpersonate endpoint that re-issues the admin token
from that claim. The admin token no longer needs to be stored in
sessionStorage, eliminating the risk of token theft via XSS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-19 23:32:08 -07:00
parent f6cc7a606e
commit 6d09e40f58
4 changed files with 45 additions and 14 deletions

View File

@@ -118,8 +118,6 @@ async function toggleUser(id, disable) {
async function impersonateUser(id) {
try {
const data = await API.post(`/api/admin/users/${id}/impersonate`, {});
// Save admin token so user can return
sessionStorage.setItem('admin_token', Auth.getToken());
Auth.setToken(data.access_token);
window.location.href = '/';
} catch (err) {