Repository navigation
Prepare for the Identity cutover (napbat/identity#77) - #51
Merged
Merged
Conversation
Identity (napbat/identity#77) refuses a refresh token with invalid_grant after a password, email, MFA, or session-revocation change rotates the account's security stamp. semctl reported the raw OAuth error body. It now tells the user to run `semctl auth login`.
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 breaks without it
Identity PR napbat/identity#77 makes a refresh token fail with
invalid_grantafter the account's security stamp rotates. Password, email, MFA changes and "revoke all sessions" rotate the stamp. Production Identity minted a new token in that case. The new one does not.After the swap, every semctl command (and every MCP tool call) for that user fails until they log in again. semctl showed only the raw OAuth body:
What changed
src/auth/mod.rs: when/connect/tokenrefuses a refresh withinvalid_grant, semctl now says the stored login is no longer accepted and tells the user to runsemctl auth login. Other token errors keep the old message. The change is client-side only, so it works with the current production Identity and with the new one.src/auth/tests.rs: two regression tests (theinvalid_grantpath, and that other errors stay unchanged). The test token server now takes a status line.The other semctl calls to Identity need no change:
POST /connect/deviceand thedevice_codegrant: clientsemctx-cli(public, implicit consent), scopessemctx.api offline_access. The token audience issemctx-api. Device verification has no consent step, and the request has noopenid, soprompt/max_agedo not apply.GET /v1/tenantswith thatsemctx-apitoken: this endpoint accepts a delegated user token ([AcceptsDelegatedUserToken]).Checks run
Against
napbat/identity-server:cutover(d77ff9c), with thesemctx-cliclient frombootstrap/identity-oauth.json, using the realsemctlbinary:semctl auth login --no-open: device flow completes and the tenant is selected automatically (GET /v1/tenants→ 200). Token:aud=semctx-api,scope=semctx.api offline_access,client_id=semctx-cli.semctl auth tenants→ 200. With the stored token forced to expire, the refresh succeeds and the refresh token rotates.PATCH /v1/account/password(and, in a separate run,POST /v1/account/sessions/revoke): the old access token onGET /v1/tenants→ 401 with the envelope body. The forced refresh →invalid_grant, and semctl prints the new message.Repository gate:
cargo fmt --check,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo nextest run --workspace --locked(571 passed, 2 skipped),RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --locked, andgit diff --checkall pass.