Repository navigation
CV2-6749: Treat inactive workspaces like deleted ones in permission checks - #2464
Conversation
…eleted-ones-in-permission-checks
caiosba
left a comment
There was a problem hiding this comment.
Thanks @melsawy, the approach looks right. Requesting changes:
@context_team = nilinAbilitycan raise viaTeam'safter_find- API key auth should reject keys of inactive teams
cached_teamsandcurrent_teamstill include inactive teams- Would be good to add a few basic tests
caiosba
left a comment
There was a problem hiding this comment.
Thanks, the Ability crash and current_team are fixed. Still requesting changes:
- Regarding
api_key_perms: the conditionalcannotblocks stop applying when the team is inactive, so broader can rules win (e.g.can :create, User)... maybe keep them unconditional and addcannot :manage, :all if @api_key.team.inactive? or reject the key at auth? cached_teamsis only filtered when a membership is added... existing members of a workspace deactivated later keep it, members added while inactive lose access after reactivation... Suggest filtering on read, or updating on activate/deactivate- Would be good to add some tests for
User#role/load_context_teamwith an inactive team, a user in both an active and an inactive workspace, and bulk mutations
Done |
There was a problem hiding this comment.
I think there are still some issues, could you please confirm:
- I think Caio's second point still breaks, I think
team_user.rb:67-69deletes inactive teams from the stored list, and skips adding anyone to an inactive team, so members lose access after reactivation. - I think
bot_permissionsignoresinactive(ability.rb:177-196), so an admin of an inactive team can still update or destroy its bots and bot installations. - If we shouldn't read anything from an inactive team, we probably should do something about check_basic_abilities.rb:80-88: it checks whether the team is private but not whether it's inactive, and creators can still read their own items.
I added some tests temporarily and they all failed:
- test/models/team_user_test.rb (at the end of the file)
- test "should restore access for member added while team was inactive after reactivation" do
- test "should keep inactive team in cached teams when another membership changes" do
- test/models/ability_test.rb
- test "should not read items of public inactive team" do (after "read ability for user in private team with member status")
- test "should not read own items in inactive team" do (same place)
- test "admin of inactive team should not manage its bots or bot installations" do (after "permissions for team bot installation")
If you want, I can push my tests to this branch.
Yes @vasconsaurus please push your tests |
|
Thanks, @vasconsaurus , for adding the unit tests. They were very helpful. |
|
@melsawy, glad it helped! Will re-review today |
is_owner_of_bot_team ignored team status, so inactive-team admins could still manage its bots, installations and API keys.
vasconsaurus
left a comment
There was a problem hiding this comment.
@melsawy, I found what I think was a last small gap, I added a couple of tests to confirm, and updated the is_owner_of_bot_team check to filter out inactive teams. Please do rollback if you think this doesn't make sense.
Otherwise everything else looks good to me
Description
Verify that the team is active before checking permissions.
References: CV2-6749
How to test?
Checklist