Prevent self-service backup restore from re-granting revoked provider channels#600
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37661b571f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| SELECT uc.provider_channel_id | ||
| FROM user_channels uc | ||
| JOIN user_categories cat ON cat.id = uc.user_category_id | ||
| WHERE cat.user_id = ? |
There was a problem hiding this comment.
Exclude hidden channels when deriving restorable provider IDs
The new authorization snapshot treats all user_channels rows as currently granted, but channel revocation paths (deleteUserChannel/bulkDeleteUserChannels) mark rows as hidden (is_hidden = 1) instead of deleting them. In that case, a non-admin restore still includes those provider IDs in allowedProviderChannelIds, and the restore re-inserts them as visible channels, so revoked channels can be re-granted despite this fix. The authorization query should filter to active assignments (for example uc.is_hidden = 0) when building the allowed set.
Useful? React with 👍 / 👎.
Motivation
Description
restoreBackupand use it to filterdata.userChannelsbefore reinserting channels.req.user.is_adminis true.docs/API_REFERENCE.mdto state that self-service restores are allowed but cannot re-grant revoked channels.tests/controllers/backupController.test.jsthat verify non-admin restores filter out revoked provider channels and admins restore all backed up channels.Testing
tests/controllers/backupController.test.jswithvitestand the new tests passed.INSERTcalls for channels.Codex Task