Repository navigation
fix(sessions): a password change ends the sessions opened before it - #13
Merged
Merged
Conversation
A refresh token is good for seven days and for a new pair each time, and the refresh never read the account again: a copy of a token went on working after the password was changed, and after the account was gone. The account now numbers its sessions (SessionVersion). The refresh token carries the number the row had when it was made, in the token's ID: Common's claims have no field for it, and every service reads them. The refresh reads the account again and answers 401 when it is gone or at another session. - A password change, and the reset from the command line, add one to the number: every session opened before ends. - The password change answers with the body of a login, so that the session that made the change goes on with a pair of the new session. - A new account starts at a number of its own, not at 0: the database gives the id of an account that is gone to the next one made, and a token of the first is not of the second. - A token made before sessions were numbered says nothing and is of session 0, like the accounts that were there: an update signs nobody out. - Saving a profile leaves the number alone.
inkly
marked this pull request as ready for review
November 10, 2026 22:33
inkly
added a commit
to ReCasaOS/CasaOS-UI
that referenced
this pull request
Nov 10, 2026
…tokens the change answers with (#175) A password change now ends every session of the account, the one that made it too, and the user service answers with the pair that session goes on with (ReCasaOS/CasaOS-UserService#13). The account panel stores it where the requests and the message bus read their token. An older user service answers with the user alone, and the session is left as it is.
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.
A refresh token is good for seven days and for a new pair each time, and
POST /v1/users/refreshnever read the account again. A copy of a token went on working after the password was changed, and after the account was gone.What changes
SessionVersionon the user row, added by the migration). The refresh token carries the number the row had when it was made, in the standardjticlaim: Common's claims have no field for it, and every service reads them.401when it is gone or at another session.PUT /v1/users/current/password) and the reset from the command line add one to the number: every session opened before ends.For the callers
PUT /v1/users/current/passwordnow answers with the body of a login (tokenanduser), where it answered with the user alone: the session that made the change goes on with that pair. The dashboard stores it in ReCasaOS/CasaOS-UI (pull request to come); an older dashboard ignores the body and is asked to sign in again when its token runs out.Tests
route/v1_sessions_test.go, each failing before its change:go test ./...passes on the four packages.