Skip to content

Commit 279146c

Browse files
committed
Cleanup
1 parent 4125673 commit 279146c

File tree

2 files changed

+11
-8
lines changed
  • libs/galley-types/src/Galley/Types
  • services/brig/src/Brig/Team

2 files changed

+11
-8
lines changed

libs/galley-types/src/Galley/Types/Teams.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module Galley.Types.Teams
5858
, noPermissions
5959
, serviceWhitelistPermissions
6060
, hasPermission
61-
, hasCopyPermission
61+
, mayGrantPermission
6262
, isTeamOwner
6363
, self
6464
, copy
@@ -395,8 +395,8 @@ serviceWhitelistPermissions = Set.fromList
395395
hasPermission :: TeamMember -> Perm -> Bool
396396
hasPermission tm p = p `Set.member` (tm^.permissions.self)
397397

398-
hasCopyPermission :: TeamMember -> Perm -> Bool
399-
hasCopyPermission tm p = p `Set.member` (tm^.permissions.copy)
398+
mayGrantPermission :: TeamMember -> Perm -> Bool
399+
mayGrantPermission tm p = p `Set.member` (tm^.permissions.copy)
400400

401401
-- Note [team roles]
402402
-- ~~~~~~~~~~~~

services/brig/src/Brig/Team/Util.hs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ ensurePermissions u t perms = do
3737
check (Just m) = and $ hasPermission m <$> perms
3838
check Nothing = False
3939

40-
-- | (Some code duplication with 'Galley.API.Teams.ensureNotElevated'.)
40+
-- | Privilege escalation detection (make sure no `RoleMember` user creates a `RoleOwner`).
41+
--
42+
-- There is some code duplication with 'Galley.API.Teams.ensureNotElevated'.
4143
ensurePermissionToAddUser :: UserId -> TeamId -> Permissions -> ExceptT Error AppIO ()
4244
ensurePermissionToAddUser u t inviteePerms = do
43-
m <- lift $ Intra.getTeamMember u t
44-
unless (check m) $
45+
minviter <- lift $ Intra.getTeamMember u t
46+
unless (check minviter) $
4547
throwStd insufficientTeamPermissions
4648
where
4749
check :: Maybe TeamMember -> Bool
48-
check (Just m) = hasPermission m AddTeamMember &&
49-
and (hasCopyPermission m <$> (Set.toList $ inviteePerms ^. self))
50+
check (Just inviter) =
51+
hasPermission inviter AddTeamMember &&
52+
and (mayGrantPermision inviter <$> Set.toList (inviteePerms ^. self))
5053
check Nothing = False

0 commit comments

Comments
 (0)