Auth logout: after an offline logout the token can no longer be revoked, and a running TUI stays signed in
Summary
If kite auth logout runs while offline, revocation fails and the local token is removed, as documented. After that:
- The CLI has discarded the only copy of the token, so it can never revoke it. The token stays valid on Kite until about 06:00 IST.
- A second
kite auth logout, run once the network is back, prints "Logged out / No saved session; nothing to revoke." That reads as a completed logout although the session is still active on Kite. - A TUI that was already open keeps working with the token it holds in memory, so the account stays live on the machine after "Logged out".
- Kite CLI commands also doesn't go through with an error "not logged in; run
kite auth login"; though the session is live
Steps to reproduce
- Sign in and open the TUI in one terminal:
kite& login with credentials - Disconnect from the internet.
- In a second terminal:
kite auth logout - Reconnect to the internet.
- The TUI in the first terminal goes back to
liveand loads account data again. - In the second terminal, run
kite auth logoutagain. - The TUI is still
live.
Expected
After step 6 the session is ended on Kite, or the output says clearly that it is not. The TUI returns to the sign-in screen.
Actual
Step 3:
warning: could not revoke the session on Kite: Kite login request failed; the token may remain active until expiry. Sign in on Kite and log out there to revoke it
✓ Logged out
Session removed from ~/Library/Application Support/kite/config.json; the token expires at 6 AM IST
Step 6:
✓ Logged out
No saved session; nothing to revoke.
At step 7 the session is still active on Kite and usable from the open TUI.
Cause
In logout (src/commands/auth.rs, line 29), rt.clear_session() on line 54 runs whether or not invalidate succeeded. The next run finds no access_token in config.json, skips revocation, and prints the "nothing to revoke" branch (line 73). The TUI does not re-read config.json after startup, so it is unaffected by the cleared session.
Possible solutions
- A. Retry later. When revocation fails, keep the token in a separate pending-revocation field. The CLI stays logged out locally, and the next
kite auth logout(or next command) retries the revoke. This keeps the documented local behaviour. - B. Keep the session on network failure. Leave
access_tokenin place so a later logout can revoke it, with a flag to force local removal. Simpler, but changes the documented behaviour and leaves the token usable on disk. - C. Sign the TUI out. Have the TUI notice that the saved session was cleared and return to the sign-in screen, as it already does on
TokenException. - D. Wording only. Make the offline warning say that a running TUI stays signed in, and make the second logout say that an earlier revocation failed.
A and C together would close the gap; D is the minimum. I'm happy to send a PR for whichever direction you prefer.
Environment
macOS, kite 0.2.3. The code path is not platform-specific, so Linux and Windows should behave the same; I have only tested macOS.