Skip to content

Commit

Permalink
Fail on MLS endpoint if MLS is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Dec 9, 2022
1 parent e4c75c1 commit 92351a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions services/brig/brig.integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ optSettings:
setDpopMaxSkewSecs: 1
setDpopTokenExpirationTimeSecs: 300 # 5 minutes
setPublicKeyBundle: test/resources/jwt/ed25519_bundle.pem
setMLSEnabled: true

logLevel: Warn
# ^ NOTE: We log too much in brig, if we set this to Info like other services, running tests
Expand Down
8 changes: 6 additions & 2 deletions services/brig/src/Brig/API/MLS/KeyPackages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ where
import Brig.API.Error
import Brig.API.Handler
import Brig.API.MLS.KeyPackages.Validation
import Brig.API.MLS.Util
import Brig.API.Types
import Brig.App
import qualified Brig.Data.Client as Data
Expand All @@ -48,6 +49,7 @@ import Wire.API.User.Client

uploadKeyPackages :: Local UserId -> ClientId -> KeyPackageUpload -> Handler r ()
uploadKeyPackages lusr cid (kpuKeyPackages -> kps) = do
assertMLSEnabled
let identity = mkClientIdentity (qUntagged lusr) cid
kps' <- traverse (validateKeyPackage identity) kps
lift . wrapClient $ Data.insertKeyPackages (tUnqualified lusr) cid kps'
Expand All @@ -57,7 +59,8 @@ claimKeyPackages ::
Qualified UserId ->
Maybe ClientId ->
Handler r KeyPackageBundle
claimKeyPackages lusr target skipOwn =
claimKeyPackages lusr target skipOwn = do
assertMLSEnabled
foldQualified
lusr
(withExceptT clientError . claimLocalKeyPackages (qUntagged lusr) skipOwn)
Expand Down Expand Up @@ -131,7 +134,8 @@ claimRemoteKeyPackages lusr target = do
handleFailure = maybe (throwE (ClientUserNotFound (tUnqualified target))) pure

countKeyPackages :: Local UserId -> ClientId -> Handler r KeyPackageCount
countKeyPackages lusr c =
countKeyPackages lusr c = do
assertMLSEnabled
lift $
KeyPackageCount . fromIntegral
<$> wrapClient (Data.countKeyPackages lusr c)
5 changes: 4 additions & 1 deletion services/brig/src/Brig/API/MLS/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ module Brig.API.MLS.Util where

import Brig.API.Error
import Brig.API.Handler
import Brig.App
import Brig.Data.Client
import Brig.Options
import Control.Error
import Control.Lens (view)
import Imports

isMLSEnabled :: Handler r Bool
isMLSEnabled = pure False
isMLSEnabled = fromMaybe False . setMLSEnabled <$> view settings

assertMLSEnabled :: Handler r ()
assertMLSEnabled =
Expand Down

0 comments on commit 92351a8

Please sign in to comment.