fix(clerk_auth): authenticate the DELETE that signs out - #446
Open
dbeattie71 wants to merge 1 commit into
Open
Conversation
`_delete` cleared the token cache before building the request. `_headers` attaches the Authorization header only while the cache still holds a client token, and `_queryParams` reads `sessionId` from the same place, so the DELETE went out identifying neither client nor session. The back end answers 200 to that request without revoking anything, and `signOut` returns `Client.empty` regardless, so the caller discards its local state and reports success. Sign-out therefore became a local forget: the session stays active until it expires naturally, and any token already minted from it stays valid. Verified against a live instance — a session queried through the Backend API immediately after a successful-looking sign-out still reported `status: active`. `deleteUser` uses the same helper via `DELETE /me` and is worse off, because `requiresSessionId: true` also reads the cleared `sessionId`. It reports deleting an account it has not deleted. Building the headers first fixes both. The clear moves into a `finally` so local credentials are still dropped when the request fails — a sign-out that cannot reach the network must still sign the user out of this device. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #445.
_deletecleared the token cache before building the request._headersattachesAuthorizationonly while the cache still holds a client token, and_queryParamsreadssessionIdfrom the same place, soDELETE /v1/clientwent out identifying neither client nor session.The back end answers 200 to that without revoking anything, and
signOutreturnsClient.emptyregardless, so the caller discards its local state and reports success. Sign-out was a local forget: the session stays active until it expires naturally, and any token minted from it stays valid. Verified against a live instance — a session queried through the Backend API immediately after a successful-looking sign-out still reportedstatus: active, with its originalabandon_ata month out.deleteUser()shares the helper viaDELETE /meand is worse off, sincerequiresSessionId: truealso depends on thesessionIdcleared on that same line. It reports deleting an account it has not deleted.The change
The
finallyis deliberate: local credentials must be dropped whether or not the request succeeds, so a sign-out that cannot reach the network still signs the user out of that device.Tests
sign_out_authentication_test.dart— asserts the sign-out DELETE carries the client token. Confirmed failing before the fix (Expected: <true> Actual: <null>).finallyso a later refactor cannot quietly reintroduce a sign-out that leaves the user signed in offline.clerk_authsuite green: 647 passing.Note
Independent of #444, which fixes the identifier-casing bug in
attemptSignIn. The two do not overlap and can land in either order.