Repository navigation
user: moving a user moves its permission rows - #92
Merged
Merged
Conversation
A user's explicit permission row stayed in the old group after a move,
so Permission.get({ uid }) reported a group the user had left. On mysql
the nt_user and nt_perm updates share a transaction and every one of
the user's rows moves, deleted ones too. The file stores move the
inline permission with the user.
An inheritance change in the same PUT runs in that transaction under a
lock on the user's row, so a failure rolls back the move as well.
Going explicit after a revoke gives the user fresh permissions on every
store instead of a create conflict or the revoked grants.
There was a problem hiding this comment.
🟡 Changes recommended
Resetting file-backed permissions can duplicate permission IDs and cause later operations to target another user.
1 open finding
What changed in this PR
Keeps user permissions aligned with group moves and resets revoked permissions when users switch back to explicit permissions.
Changes:
- Moves MySQL permission rows transactionally with their user.
- Updates file-backed permission groups and resets revoked grants.
- Adds regression tests and a changelog entry.
| File | Description |
|---|---|
| lib/user/test/mysql.js | Tests rollback, missing users, and permission resets. |
| lib/user/test/index.js | Tests explicit permissions following user moves. |
| lib/user/store/mysql.js | Makes moves and permission changes transactional. |
| lib/user/store/file.js | Updates permission groups and resets revoked permissions. |
| lib/store/file.test.js | Tests permission resets for JSON and TOML. |
| CHANGELOG.md | Documents the user-move fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.

Moving a user left their explicit permission row in the old group, so
Permission.get({ uid })reported a group they had left. A move now carries the user's permission rows with it, on mysql in the same transaction as thent_userupdate.Going explicit again after a revoke used to hit a create conflict on mysql and revive the revoked grants on json and toml. Every store now starts the user fresh.