fix(dashboard): persist API key across browser sessions#238
Conversation
📝 WalkthroughWalkthroughThis change modifies API key persistence in the dashboard from memory-only storage to persisting values in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/admin/dashboard/static/js/dashboard.js`:
- Around line 339-342: The code currently persists the admin bearer token to
localStorage in saveApiKey (using API_KEY_STORAGE_KEY and normalizeApiKey) which
is XSS-exfiltrable; change persistence to a safer option and ensure invalid
submissions are cleared: replace localStorage.setItem(...) with
sessionStorage.setItem(...) (or remove client-side storage and rely on an
httpOnly cookie if you opt for server-side auth), add a public "sign out" /
"forget key" handler that calls localStorage.removeItem(API_KEY_STORAGE_KEY) and
clears this.apiKey, and update submitApiKey() to also remove the stored key
(removeItem) when a submission is rejected so a previously persisted token is
not left behind.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: acadc5f3-8bd4-4b03-bc0f-a251a0a27d56
📒 Files selected for processing (2)
internal/admin/dashboard/static/js/dashboard.jsinternal/admin/dashboard/static/js/modules/dashboard-display.test.js
Summary
Testing
Summary by CodeRabbit
New Features
Tests