-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WPB-5695 Enforce group conversation permission for external partner role #3788
Merged
battermann
merged 20 commits into
develop
from
WPB-5695-group-conversation-permission-bypass-by-external-partner-role
Jan 5, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6263a5b
on member add check permissions
battermann 40a491c
cu
battermann e998a90
external partner cannot rename conv
battermann de9bc6d
make external partner to member as soon as total of 2 members
battermann f4f6fb9
Merge remote-tracking branch 'origin/develop' into WPB-5695-group-con…
battermann 7b88634
changelog
battermann c823c1d
Merge remote-tracking branch 'origin/develop' into WPB-5695-group-con…
battermann f52f1a6
do not allow external partner to add conv members at all
battermann 8dc090d
do not allow ext partner to create group conv
battermann 3dd8d6c
comment
battermann 899f2ec
verify 1:1 MLS works for external partner
battermann 9fa990e
removed redundant code
battermann 4cac27e
Update integration/test/SetupHelpers.hs
battermann f638a76
Update integration/test/Test/ExternalPartner.hs
battermann c2e99be
Update integration/test/Test/ExternalPartner.hs
battermann e299332
Update services/galley/src/Galley/API/Action.hs
battermann dfe65c8
Update services/galley/src/Galley/API/Create.hs
battermann d203365
fix
battermann 073d758
remove prefix from team permissions
battermann aba9ad1
linting
battermann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Enforce external partner permissions on the backend |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{-# OPTIONS_GHC -Wno-ambiguous-fields #-} | ||
|
||
-- This file is part of the Wire Server implementation. | ||
-- | ||
-- Copyright (C) 2023 Wire Swiss GmbH <opensource@wire.com> | ||
-- | ||
-- This program is free software: you can redistribute it and/or modify it under | ||
-- the terms of the GNU Affero General Public License as published by the Free | ||
-- Software Foundation, either version 3 of the License, or (at your option) any | ||
-- later version. | ||
-- | ||
-- This program is distributed in the hope that it will be useful, but WITHOUT | ||
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
-- details. | ||
-- | ||
-- You should have received a copy of the GNU Affero General Public License along | ||
-- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
module Test.ExternalPartner where | ||
|
||
import API.Galley | ||
import GHC.Stack | ||
import MLS.Util | ||
import SetupHelpers | ||
import Testlib.Prelude | ||
|
||
testExternalPartnerPermissions :: HasCallStack => App () | ||
testExternalPartnerPermissions = do | ||
(owner, tid, u1 : u2 : u3 : _) <- createTeam OwnDomain 4 | ||
|
||
partner <- createTeamMemberWithRole owner tid "partner" | ||
|
||
-- a partner should not be able to create conversation with 2 additional users or more | ||
void $ postConversation partner (defProteus {team = Just tid, qualifiedUsers = [u1, u2]}) >>= getJSON 403 | ||
|
||
do | ||
-- a partner can create a one to one conversation with a user from the same team | ||
conv <- postConversation partner (defProteus {team = Just tid, qualifiedUsers = [u1]}) >>= getJSON 201 | ||
|
||
-- they should not be able to add another team member to the one to one conversation | ||
bindResponse (addMembers partner conv def {users = [u2]}) $ \resp -> do | ||
resp.status `shouldMatchInt` 403 | ||
|
||
-- the other member in the conversation gets deleted | ||
deleteUser u1 | ||
|
||
-- now they still should not be able to add another member | ||
bindResponse (addMembers partner conv def {users = [u2]}) $ \resp -> do | ||
resp.status `shouldMatchInt` 403 | ||
|
||
do | ||
-- also an external partner cannot add someone to a conversation, even if it is empty | ||
conv <- postConversation partner (defProteus {team = Just tid}) >>= getJSON 201 | ||
bindResponse (addMembers partner conv def {users = [u3]}) $ \resp -> do | ||
resp.status `shouldMatchInt` 403 | ||
|
||
testExternalPartnerPermissionsMls :: HasCallStack => App () | ||
testExternalPartnerPermissionsMls = do | ||
-- external partners should not be able to create (MLS) conversations | ||
(owner, tid, _) <- createTeam OwnDomain 2 | ||
bobExt <- createTeamMemberWithRole owner tid "partner" | ||
bobExtClient <- createMLSClient def bobExt | ||
bindResponse (postConversation bobExtClient defMLS) $ \resp -> do | ||
resp.status `shouldMatchInt` 403 | ||
|
||
testExternalPartnerPermissionMlsOne2One :: HasCallStack => App () | ||
testExternalPartnerPermissionMlsOne2One = do | ||
(owner, tid, alice : _) <- createTeam OwnDomain 2 | ||
bobExternal <- createTeamMemberWithRole owner tid "partner" | ||
void $ getMLSOne2OneConversation alice bobExternal >>= getJSON 200 | ||
|
||
testExternalPartnerPermissionsConvName :: HasCallStack => App () | ||
testExternalPartnerPermissionsConvName = do | ||
(owner, tid, u1 : _) <- createTeam OwnDomain 2 | ||
|
||
partner <- createTeamMemberWithRole owner tid "partner" | ||
|
||
conv <- postConversation partner (defProteus {team = Just tid, qualifiedUsers = [u1]}) >>= getJSON 201 | ||
|
||
bindResponse (changeConversationName partner conv "new name") $ \resp -> do | ||
resp.status `shouldMatchInt` 403 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this creating a group conversation? I understand the idea of the team 1:1 conversation, but here we're not really creating a 1:1 conversation, are we? That it is a 1:1 conversation is a concept in Wire clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly.