Repository navigation
fix(api): require a recent sign-in for credential changes and refuse them while impersonating - #983
Open
Medformatik wants to merge 2 commits into
Open
Medformatik wants to merge 2 commits into
Medformatik wants to merge 2 commits into
Conversation
This was referenced Nov 16, 2026
…them while impersonating Changing the email address, adding or removing a passkey, linking a new provider, unlinking one and deleting the account now need the same fresh assurance as the privacy export. Impersonation sessions are refused on these routes and on the password and second-factor routes. The previous address is told after an email change, and an account holds one identity per provider. The web app shows a prompt that leads to a sign-in page and back; the person then repeats the change. Account deletion no longer asks for a password in the client.
Medformatik
force-pushed
the
fix/account-credential-reauth
branch
from
November 16, 2026 17:23
91d28c0 to
2bdf0bd
Compare
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.
What changed and why
Three account routes trusted an existing session more than they should. Changing the email address needed only a session and a code sent to the new address, with no word to the old one. Deleting the account and enrolling a passkey accepted any session younger than 24 hours, and the password prompt for deletion lived only in the web client. An administrator impersonation session could use all of these on the target account, past the re-authentication the dedicated administrator actions require.
The API now applies the privacy export's rule to these routes: a sign-in from the last ten minutes, including the second factor when one is enrolled. It covers email change (request and confirm), account deletion, adding and removing passkeys, unlinking a provider and linking a provider the account does not have yet. Requesting more OpenStreetMap scopes for an already linked account stays as it was, and an account can hold only one identity per provider so that exemption cannot attach a different one. Impersonation sessions are refused on these routes and on the password and second-factor routes. After an email change the previous address receives a short notice, unless it is a provider placeholder.
In the web app a refused change shows a prompt with a "Sign in again" button. It leads to a sign-in page and back to where the person was; they then repeat the change, and nothing resumes on its own. Account deletion no longer asks for a password, because the recent sign-in is the confirmation for every kind of account, including passkey-only and OpenStreetMap or Mapillary accounts.
Known limit: in the installed app, a passkey or provider re-sign-in goes through the system browser, which hands back its existing session when it still has one. The prompt then appears again; signing out first gets a new sign-in. The privacy export behaves the same way today.
Verification
check-typespasses forapps/api,packages/coreandapps/web; Biome, Prettier andcheck-translationspass on the touched files; the policy checks pass individually exceptcheck-image-size-dos, which could not run locally without the docs dependencies.auth-postgres.test.ts(stale session on every gated route, impersonation, the old-address notice, OpenStreetMap self-deletion and scope upgrade). They are left to CI.Release and upgrade impact
Product impact: security
No operator action. Clients that call these Better Auth endpoints directly receive
401 FRESH_SIGN_IN_REQUIREDor403 IMPERSONATION_NOT_ALLOWED.No package release: the extension CLI is counted through shared core and translation sources, but it uses neither the account error codes moved here nor the new account strings.