Repository navigation
feat(dashboard): list the API keys that stop working when you deactivate a user - #2078
Open
amarkanday wants to merge 2 commits into
Open
amarkanday wants to merge 2 commits into
amarkanday wants to merge 2 commits into
Conversation
…ate a user Clearing Active in the Edit user dialog now names the keys that will stop working, instead of only saying that some will (#657). - The dialog asks GET /api/v1/api-keys?all=true when Active is cleared on someone else's account (never on open, never for a role-only change), keeps the rows whose user_id is this user's and that are still active, and lists each key with its scopes and when it was last used. A success is kept while the dialog stays open; a failure shows the reason and a Try again button. Save is never held up by the request and still sends exactly {is_active: false}. Any superuser may call the route, whatever their role, so no backend change is needed. - Screen readers: one polite status region, empty until the request settles; Save and Active are described by the general warning and the summary; focus stays on Active, and moves to the summary only after Try again succeeds. - The delete confirm says that the account's API keys are deleted too. - Docs: auth-user-guide, endpoints and security/api-keys say how to find a user's keys, what to switch before deactivating, and that reactivating the user makes unexpired keys work again; the claims registries follow. - Tests: the dialog (26 cases), the real page against the request on the wire, the query-parameter guard (one more call), the delete confirm, the dialog-focus journey (a real key listed, axe on it), a superuser who is not an ADMIN listing every key, and a deactivated owner's key answering 401 and working again after reactivation unless it expired. No file under backend/app changes, so the OpenAPI snapshots do not move. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NpxPyav9uBxNuiXsDvD8qn Signed-off-by: amarkanday <a.markanday@gmail.com>
Brings the deactivate dialog's key list up to main 7105479. The merge was clean, but query-params.test.ts's call count was wrong after it: this branch and #2006 each added one dashboard call and each moved EXPECTED_COUNT from 16 to 17 (15 to 16 in the core profile), so the merged line still said 17 while 18 calls are made. It now says 18 (17 in core). Both calls stay listed in EXPECTED_CALLS, as the merge left them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NpxPyav9uBxNuiXsDvD8qn Signed-off-by: amarkanday <a.markanday@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #657
What and why
When an administrator cleared Active in the Edit user dialog, the dialog said that "API keys they created stop working" and nothing more. Nowhere in the dashboard could they see which keys. Now the dialog names them, before they save.
GET /api/v1/api-keys?all=true(never on open, never for a role-only change), keeps the rows whoseuser_idis this user's and that are still active, and lists each key asname · scopes · last used <date-time>(orno scopes,never used). A success is kept while the dialog stays open; a failure shows the reason and a Try again button.{is_active: false}: an emergency deactivation never needs the list.check_permissionreturns early for a superuser), and the Users page is superuser-only, so every account that can open the dialog can make the call. No file underbackend/appchanges, andmake openapileaves the tree clean.role="status"region, mounted empty and filled once when the request settles; Save and Active are described by the general warning and the summary; focus stays on Active and moves to the summary only after Try again succeeds.auth-user-guide.md,api/endpoints.mdandsecurity/api-keys.mdsay how to find a user's keys, to switch an application to a key of an account that stays before deactivating, and that reactivating the user makes their keys work again unless they expired. "An ADMIN can add?all=true" now says "or any superuser". The claims registries follow; oneexempt:baselineline leaves_frozen.tsv.Not in this change (0.49.0, #657 proper): keys owned by the organisation, listing keys in the delete confirm, and the role-change effect on
sdk:rulesetkeys (to be noted on #657).Verification
Run in a clean clone of main, a Python 3.11 venv, a scratch PostgreSQL 14 on 127.0.0.1 for the integration tests.
npx tsc --noEmit,npm run lintdoc_claims.py checkdoc_examples.py --check,test_docs_only_gate.py,backend/tests/unit/docsmkdocs build --strict,make openapiEach plant was applied to the product file, the named tests ran red, and the file was put back byte for byte (unstaged diff empty after):
aria-describedbyon Save, status region mounted with its text, summary focus on first load, status region on your own row,divchildren in theul(axelistrule)all, withinclude_inactive: both fail the page test on?all=true?in the path literal: the query-parameter guard refuses ithas_permission(user.role, ...)in_may_act_on_others_keysturns both superuser-not-ADMIN cases to 403; deactivation setting the keys inactive fails "the owner's key is 401 while they are inactive and works again"bylist, the removed ledger line back, and a doc sentence edited away from its unit each faildoc_claims.py checkNOT VERIFIED
dialog-focus.journey.spec.ts, a real key listed and axe run on it, wcag2aa colour contrast included) was type-checked and linted but not run: it needs the real API and a browser, which only the requiredbrowser-e2egate has. It makes the first rawPOST /auth/loginin the journeys project and retries a 429 the way the two-step journey does.aria-disabledbutton: jsdom does not compute or speak them.?all=trueis not paginated; its size on a site with thousands of keys was not measured.🤖 Generated with Claude Code
https://claude.ai/code/session_01NpxPyav9uBxNuiXsDvD8qn