Skip to content

Saved logins nobody may use: an admin can count and delete them, and the Vault keeps them deletable - #2166

Merged
davidmckayv merged 8 commits into
mainfrom
api/saved-logins-purge
Nov 25, 2026
Merged

davidmckayv merged 8 commits into
mainfrom
api/saved-logins-purge

Conversation

@jpr5

@jpr5 jpr5 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

An admin can turn the Password manager switch off, and people can be removed from an organization, but the logins they saved stay behind, hidden and unusable, with no way to delete them in bulk. This PR:

  1. adds an API operation that lets an admin delete those saved logins in one go, and a read that says how many it would delete first;
  2. fixes the switch's description in the spec's examples;
  3. adds the screens: an admin's delete button beside the switch, a Vault that keeps the list and its delete buttons while saving is off, and a sign-in form a person's own password manager can fill.

It merges together with the server handler, not before. Merged alone, main would advertise two operations no server serves. The handler is built against this branch and lands with it.

The operations

POST /api/v2/organizations/{organizationId}/saved-logins/purge, purgeSavedLogins, tag Saved logins. It takes no body and needs an Idempotency-Key. It deletes saved logins, passwords included, in two groups:

  1. Switched off: every current member the Password manager switch is off for. The switch is read for each person as it applies to them, by role, directory groups and teams, as getPersonCapabilities answers it. A group or team that turns the switch back on for its members keeps their logins.
  2. Removed: every person removed from the organization: no longer a member of it, or whose address can't sign in to this OpenBot any more.

Every other saved login stays. The answer counts what was deleted in each group:

{ "deleted": { "switchedOff": 12, "removed": 3 } }

GET /api/v2/organizations/{organizationId}/saved-logins/unusable, getUnusableSavedLogins, tag Saved logins. It counts, without deleting anything, exactly what purgeSavedLogins would delete at that moment, in the same two groups, so a confirmation can say "Delete 15 saved logins?" with real numbers:

{ "switchedOff": 12, "removed": 0 }

The two counts are one schema, SavedLoginCounts, shared by both answers (the purge's deleted is that schema; its shape is unchanged).

The removed group is almost always 0. Removing somebody already deletes their saved logins, and a daily sweep deletes any left behind. The group is a safety net, so a 0 there is expected and not a bug. Both operations' descriptions now say so.

Admin only. Only an administrator of the organization may call either (403 AdminOnly otherwise). The personal edition has no switches to set and nobody to remove, so it serves neither and answers 404. The purge is modelled on the existing admin actions stopInactiveComputers and stopPersonComputers: the same security, Idempotency-Key, Cache-Control: private, no-store, and error responses (400, 401, 403 AdminOnly, 404 OrganizationNotFound, 409 IdempotencyConflict, 500, default). The read has the same minus the write-only ones (401, 403 AdminOnly, 404 OrganizationNotFound, 500, default), and is marked x-openbot-singleton like getSetupChecklist. The counts are integer with minimum: 0, the way the spec types counts.

Scopes. saved-logins:write now also covers the purge for an administrator, and saved-logins:read the count, the way people:write and settings:write cover their admin actions. Only the scopes' descriptions change. oasdiff reports them as info.

The switch's wording

The capabilities examples (CapabilityPageExample and CapabilityExample in api/openapi/admin-settings.yaml, and so api/openapi.yaml) still said "People may save logins and hand sign-ins to a Bot's browser." The switch covers saving logins and using a saved one, not typed sign-ins. The server now labels it "People may save logins, and sign a Bot in with a login they saved.", and both examples now use that text. The only other copy was the app client's generated mock data (capabilities.msw.ts), which was regenerated from the spec. No app screen hard-codes the old text.

The screens

  • Admin, Permissions: "Saved logins nobody may use". A row under the Password manager switch, always there for an admin: whether the switch is off for anybody depends on each person's role, teams and directory groups, which only the server reads, and people who left can have logins whatever the switch says. Delete opens a dialog that first reads the counts and asks with them: "Delete 15 saved logins? 12 are from people Password manager is off for, and 3 from people no longer in the organization. Their passwords are deleted with them. You can't undo this." The counts are read afresh each time. With nothing to delete it says so and offers no delete. Delete them calls purgeSavedLogins with a fresh Idempotency-Key (idempotencyKey(), as every generated write does), and the row then says what was deleted, for each reason. A failure is said the way the app says failures (loadFailure for the read, failureSaid for the purge).
  • An OpenBot without these operations. The deployment answer can't say whether a server serves them, and the spec is not the place to add a flag for two unreleased operations. So the app reads the API's plain not found (NOT_FOUND, or a 404 with no code), on the count or the purge, as "this OpenBot doesn't serve it", the way it already reads an older OpenBot without the terms or plan operations (olderOpenBot in lib/service-terms/queries.ts, planQueryOptions). The row then says "This OpenBot can't do this yet. Update it first." and stops offering the button, and nothing is drawn as a failure. ORGANIZATION_NOT_FOUND is not read that way; the app handles it once for every screen. The personal edition, which answers 404 by design, never shows the row: its Permissions page has no switches.
  • The Vault, with saving turned off. It used to put "Saved logins are off" in place of the list, so a person could see that their logins were kept but couldn't delete them, though the server still lists them and deleting one isn't behind the switch. The list now stays, each row with its delete button, under a first row: "Saved logins are off. An admin turned them off. These logins won't be offered or used. You can delete them." With nothing saved, the Vault says what it said before.
  • The sign-in form. Its fields say what they are (username, current-password), but the <form> said autocomplete="off", which can only get in the way of a person's own password manager filling them. The form no longer says it. Nothing else on the form changes.

Commits: the purge operation, the wording, the Vault list, the sign-in form, the count operation, the delete button.

Where it runs

  • New state that outlives a request? None. Spec, generated client and screens only. No server code.
  • What happens on the second replica? Nothing changes here: the handler is a separate PR that lands with this one.
  • Anything serialised? None here. The handler's PR answers this.
  • Anything fanned out to a browser? No. The admin's dialog reads the count when it opens; nothing is pushed.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway. No acting code changes here.
  • The purge's description says it is recorded on the audit trail. The handler writes that row. The count deletes nothing and records nothing.
  • Nothing new is trusted from the client. Neither operation takes a body. The screens render the server's counts and refusals; the admin check is the server's (403 AdminOnly).

API and database

  • It changes api/ and keeps every rule in docs/api-and-migrations.md. It adds two operations and one shared schema, and changes two example strings and two scope descriptions. Nothing is removed, renamed or tightened. Nothing is added to api/accepted-breaking-changes.md. bun run api:generate was run, and the sources, bundle and app client are committed together. There is no database change and no release-policy.json change.
  • The app's requests: the new calls go through the generated client (getUnusableSavedLogins, purgeSavedLogins) from lib/passwords/queries.ts and lib/passwords/mutations.ts, never from a component. The purge sends Idempotency-Key: idempotencyKey().
  • The branch is merged with main (no rebase), so it carries the passkey fields from API: name a page that asks for a passkey in a Bot's computer #2147 and the backend can pin its head.

Changelog

  • No line in this PR: the purge and the count do nothing until the server serves them, and the handler's PR adds the line. The Vault and sign-in form changes are small screen fixes that ride with it; say if you want them in the handler's line.

Proof

The count operation (5017f3fe)

RED: api/openapi-saved-logins.test.ts, extended first, against the spec without the read:

Expected: "getUnusableSavedLogins"
Received: undefined
(fail) an administrator reads, without deleting anything, the two counts the purge would delete
(fail) the read's answer is the two counts, and every example the spec shows parses
Expected to contain: "almost always 0"
(fail) both say the removed group is a safety net, almost always 0
 2 pass
 3 fail

GREEN, and again after merging main (head cdad274c):

$ bun test api/openapi-saved-logins.test.ts
 5 pass
 0 fail
$ bun run api:generate; git status --porcelain
(clean)
$ bun run api:lint
Woohoo! Your API descriptions are valid. 🎉
$ oasdiff breaking <main's api/openapi.yaml> api/openapi.yaml --flatten-allof \
    --deprecation-days-stable 365 --deprecation-days-beta 365 --fail-on WARN \
    --err-ignore api/accepted-breaking-changes.md --warn-ignore api/accepted-breaking-changes.md
No breaking changes to report, but the specs are different.   (exit 0)
$ oasdiff changelog
4 changes: 0 error, 0 warning, 4 info
info [api-security-component-oauth-scope-changed] saved-logins:read description
info [api-security-component-oauth-scope-changed] saved-logins:write description
info [endpoint-added] POST /api/v2/organizations/{organizationId}/saved-logins/purge
info [endpoint-added] GET /api/v2/organizations/{organizationId}/saved-logins/unusable
$ bun test api
 133 pass
 0 fail

The screens

Each screen has a test in the app's own style, drawn for real: the component with its own queries and mutations, through the generated client, against a server at the API's addresses (the purge's tests serve the spec's own MSW handlers). Each was run on the unchanged code first.

RED:

app/tests/vault-saved-logins-switched-off.test.tsx
(fail) with saving turned off, the Vault still lists the logins, each with its delete button, under a notice
(fail) with saving turned off, a delete button deletes that login
 1 pass   (with saving on, the list has no notice)
 2 fail

app/tests/sign-in-form-autofill.test.tsx
Expected: not "off"
(fail) the login form leaves autofill to the person's password manager
 0 pass
 1 fail

app/tests/purge-saved-logins.test.tsx
Unable to find role="button" and name "Delete saved logins nobody may use"   (before the row existed)
Unable to find an element with the text: Delete 15 saved logins?            (before the dialog read the count)
(fail) an admin is asked first with the real counts, then the purge runs and both counts are shown
(fail) the counts are read again each time the admin asks
(fail) Cancel deletes nothing
(fail) with nothing to delete, the dialog says so and offers no delete
(fail) an OpenBot that doesn't serve the count says so, as no failure, takes the button away and deletes nothing
(fail) an OpenBot that counts but doesn't serve the purge says so too, as no failure
(fail) a count that fails is said as a failure, and nothing can be deleted
(fail) a purge that fails is said as a failure, and the admin can try again
 1 pass   (the personal edition shows no button)
 8 fail

GREEN, the same tests:

$ bun test app/tests/purge-saved-logins.test.tsx app/tests/vault-saved-logins-switched-off.test.tsx \
    app/tests/sign-in-form-autofill.test.tsx app/tests/no-bot-computers.test.tsx \
    app/tests/isolated-bots-permission.test.tsx app/tests/sign-in-code-after-password.test.tsx \
    api/openapi-saved-logins.test.ts
 39 pass
 0 fail
$ (cd app && bun run typecheck)    exit 0
$ bun run format:check             exit 0
$ bun run lint                     exit 0

Mutation: each change reverted alone, its test run, the file restored byte for byte.

vault: list replaced by the off notice again          2 fail (the two "saving off" tests)
autofill: autoComplete="off" back on the login form   1 fail
purge: row not rendered beside the switch             8 fail
purge: a plain not found treated as a failure         2 fail (the two "doesn't serve" tests)

Seen in a browser. The app on its Vite dev server, every /api request answered in the API's shapes, in headless Chromium at 375×667, 430×932 and 1440×900:

  • Vault, saving off: the "Saved logins are off" row (An admin turned them off. These logins won't be offered or used. You can delete them.), then both logins, each with its delete button. Nothing cut off at any width.
  • Admin, Permissions: "Saved logins nobody may use" under Password manager, with its sentence and Delete. Its sentences wrap in full; at first they stopped at two lines on a phone, which the screenshots caught and the row now allows.
  • The confirmation: Delete 15 saved logins? with 12 are from people Password manager is off for, and 3 from people no longer in the organization. Their passwords are deleted with them. You can't undo this., Cancel and a red Delete them. Inside the window at every width.
  • After: the row says Deleted 12 saved logins of people it's off for, and 3 of people no longer in the organization.

The purge operation and the wording (66250fd6, d990b595)

RED, before the change (main at 8e5bf1df):

$ grep -c "saved-logins/purge\|purgeSavedLogins" api/openapi.yaml
0
$ bun run api:generate; git status --porcelain
(clean)
$ bun run api:lint
Woohoo! Your API descriptions are valid. 🎉

The new api/openapi-saved-logins.test.ts was written first and run against the unchanged spec:

Expected: "purgeSavedLogins"
Received: undefined
(fail) only an administrator purges saved logins, with no body and an Idempotency-Key
(fail) the answer counts each group, and every example the spec shows parses
 0 pass
 2 fail

It checks the path, operationId, tag, that there is no body, the saved-logins:write scope, the Idempotency-Key, 403 AdminOnly, and that the description names the personal edition. It also checks that the generated PurgeSavedLoginsResponse zod schema parses every example, refuses a missing count, and refuses a negative count.

GREEN, after the change (head d990b595):

$ bun run api:generate; git status --porcelain
(clean: the bundle and every generated client match the sources)
$ bun run api:lint
api/openapi.yaml: validated in 890ms
api/asyncapi.yaml: validated in 14ms
Woohoo! Your API descriptions are valid. 🎉
$ oasdiff breaking <main's api/openapi.yaml> api/openapi.yaml --flatten-allof \
    --deprecation-days-stable 365 --deprecation-days-beta 365 --fail-on WARN \
    --err-ignore api/accepted-breaking-changes.md --warn-ignore api/accepted-breaking-changes.md
No breaking changes to report, but the specs are different.   (exit 0)
$ oasdiff changelog
2 changes: 0 error, 0 warning, 2 info
info [api-security-component-oauth-scope-changed] saved-logins:write description
info [endpoint-added] POST /api/v2/organizations/{organizationId}/saved-logins/purge
$ bun run api:live:diff <main's api/asyncapi.yaml> api/asyncapi.yaml
No change to api/asyncapi.yaml breaks a client.
$ bun test api shared/tests/api-deprecations.test.ts tests/no-*-copy*.test.ts \
    tests/support-window.test.ts app/tests/tolerant-reader.test.ts app/tests/schedules-generated-client.test.ts
 170 pass
 0 fail
$ (cd app && bun run typecheck)    exit 0
$ bun run format:check             exit 0
$ bun run lint                     exit 0

oasdiff 1.38.0 is the version CI pins. I checked the darwin build against the release's checksums.

Wording, before and after:

$ git grep -n "hand sign-ins"          # before
api/openapi.yaml:48292 / :48335
api/openapi/admin-settings.yaml:2377 / :2420
app/src/lib/api/generated/capabilities/capabilities.msw.ts:27 / :40
$ git grep -n "hand sign-ins"          # after
(no hits, exit 1)

🤖 Generated with Claude Code

jpr5 added 2 commits November 24, 2026 15:43
POST /api/v2/organizations/{organizationId}/saved-logins/purge (purgeSavedLogins)
deletes, in one go, the saved logins of two groups: current members the
Password manager switch resolves off for, read per person by role, directory
groups and teams, so a group or team that turns it back on keeps its members'
logins; and people removed from the organization, either no longer members
or whose address can't sign in any more. It takes no body and answers
{ deleted: { switchedOff, removed } }, each a count. Admin only, with an
Idempotency-Key; not served on the personal edition.

saved-logins:write now also covers this for an administrator, as people:write
and settings:write cover their admin actions. Additive only; the app client
is regenerated (the phone app's and the Recorder's don't carry saved logins).
The capabilities examples still described the switch as "People may save
logins and hand sign-ins to a Bot's browser." The switch covers saving logins
and using a saved one, not typed sign-ins, and the server now describes it as
"People may save logins, and sign a Bot in with a login they saved." Both
examples say that now. Text only; the app client's mock data is regenerated.

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec itself is right. It follows the existing admin actions (stopInactiveComputers): admin only, Idempotency-Key, no body, 403 AdminOnly, and a 404 on the personal edition. It's additive, oasdiff only reports info, and the test was proven red, then green. The wording fix for the Password manager switch is right too.

Three things before it merges:

  1. Merge it with its handler, not before. The one-API rule is that a spec PR merges only once its server side is ready, and the backend PR then pins exactly that commit. Merged alone, main would advertise an operation no server serves, and the generated client would offer a call that 404s everywhere. Build the handler against this branch, and land the two together.

  2. Let the admin see what it will delete before it deletes it. This removes secrets, it can't be undone, and the answer only says what's gone. The button will want to say "Delete 15 saved logins?" first. A read that returns the same two counts would do it, without deleting anything: for example GET /api/v2/organizations/{organizationId}/saved-logins/unusable returning { switchedOff, removed }. Then the confirm dialog shows real numbers.

  3. The "removed" group will almost always be 0 now. #613 deletes logins on every removal path and runs a daily sweep, so this group only catches what's left between sweeps. Keeping it is fine as a safety net, but worth saying so in the description, so nobody reads a 0 there as a bug.

jpr5 added 5 commits November 24, 2026 16:28
…dmin turns saving off

With the Password manager switch off, the Vault put "Saved logins are off" in
place of the list. The server still lists the person's saved logins there,
and deleting one isn't behind the switch, so the person could see that
logins were kept but had no way to delete them.

The list now stays, each row with its delete button, under a first row that
says saving is off: "An admin turned them off. These logins won't be offered
or used. You can delete them." With nothing saved, the Vault says what it
said before, and an OpenBot with no computers for Bots still says that.

Drawn for real against the API's addresses: with saving off, both logins and
their delete buttons show under the notice, and a delete button deletes its
login; with saving on, there is no notice.
The private sign-in form's username and password fields say what they are
(autocomplete "username" and "current-password"), but the form around them
said autocomplete="off", which can only get in the way of a person's own
password manager filling them. The form no longer says it. The fields, the
verification code form and everything else on the form are unchanged.

Rendered for real: the login form carries no autocomplete="off", and its
fields still name themselves.
…ore it deletes any

GET /api/v2/organizations/{organizationId}/saved-logins/unusable
(getUnusableSavedLogins) counts, without deleting anything, exactly what
purgeSavedLogins would delete at that moment, in the same two groups:
current members the Password manager switch is off for, and people removed
from the organization. It answers { switchedOff, removed }. Admin only, under
saved-logins:read; the personal edition doesn't serve it and answers 404, as
it doesn't serve the purge. A confirmation can now say "Delete 15 saved
logins?" with real numbers before a purge that can't be undone.

The two counts are one schema, SavedLoginCounts, shared with the purge's
answer ({ deleted: SavedLoginCounts }, the same shape as before). Both
operations now say the removed group is almost always 0: removing somebody
already deletes their saved logins and a daily sweep deletes any left behind,
so the group is a safety net and a 0 there is expected.

Additive only (oasdiff against main: no breaking changes; the endpoint and
the saved-logins:read scope's wording are info). The app client is
regenerated; the phone app's and the Recorder's don't carry saved logins.
…ng how many

Under the Password manager switch, a new row lets an admin delete, in one go,
the saved logins of people the switch is off for and of people no longer in
the organization. The row is always there beside the switch: whether the
switch is off for anybody depends on each person's role, teams and directory
groups, which only the server reads, and people who left can have logins
whatever the switch says.

Delete opens a dialog that first reads how many it would delete
(getUnusableSavedLogins) and asks with those numbers: "Delete 15 saved
logins? 12 are from people Password manager is off for, and 3 from people no
longer in the organization. Their passwords are deleted with them. You can't
undo this." The counts are read afresh each time. With nothing to delete it
says so and offers no delete. On Delete them, purgeSavedLogins runs with an
Idempotency-Key, and the row then says what was deleted, for each reason.

An OpenBot that doesn't serve these yet (released before them) can't be told
apart by its deployment answer, so the API's plain not found (NOT_FOUND, or a
404 with no code), on the count or the purge, is read as that: the row says
"This OpenBot can't do this yet. Update it first." and stops offering it,
and nothing is said as a failure. This is how the app already reads an
OpenBot without the terms or the plan operations. Any other refusal is said
as one. The personal edition shows no Permissions switches, so no row.

Drawn for real against the spec's own MSW handlers: the counts in the
dialog, nothing deleted before Delete them or on Cancel, the key sent, both
counts shown after, nothing to delete, a count or purge not served, a count
or purge that fails, and the personal edition.
@jpr5 jpr5 changed the title API: let an admin delete the saved logins nobody may use any more Saved logins nobody may use: an admin can count and delete them, and the Vault keeps them deletable Nov 25, 2026
@jpr5
jpr5 requested a review from davidmckayv November 25, 2026 02:18

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Both operations are additive and admin-only; the confirm dialog reads fresh counts and states them before an irreversible delete, offers no delete when there's nothing; an older OpenBot reads as 'can't do this yet', not an error. Vault keeps delete when saving is off, and the sign-in form lets a password manager fill it. One copy nit for later: the success line's 'of people it's off for' would read better as 'of people Password manager is off for'. Updated onto main (it overlapped the spec bundle and generated index); merging when green on that head.

@davidmckayv
davidmckayv merged commit 31e0650 into main Nov 25, 2026
34 checks passed
@davidmckayv
davidmckayv deleted the api/saved-logins-purge branch November 25, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants