From 0b304f2ed4591a4e3067473bf5e87fcd2e0cdfa3 Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Tue, 11 Oct 2022 11:48:56 +0200 Subject: [PATCH 1/4] Refactor for clarity. --- services/spar/src/Spar/App.hs | 3 +-- services/spar/src/Spar/Scim/User.hs | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/services/spar/src/Spar/App.hs b/services/spar/src/Spar/App.hs index 3ff0204a55..7edc345b28 100644 --- a/services/spar/src/Spar/App.hs +++ b/services/spar/src/Spar/App.hs @@ -25,7 +25,6 @@ module Spar.App verdictHandler, getUserByUrefUnsafe, getUserIdByScimExternalId, - validateEmailIfExists, validateEmail, errorPage, deleteTeam, @@ -196,7 +195,6 @@ autoprovisionSamlUser idp buid suid = do guardReplacedIdP guardScimTokens createSamlUserWithId (idp ^. idpExtraInfo . wiTeam) buid suid - validateEmailIfExists buid suid where -- Replaced IdPs are not allowed to create new wire accounts. guardReplacedIdP :: Sem r () @@ -393,6 +391,7 @@ verdictHandlerResultCore idp = \case Nothing -> do buid <- Id <$> Random.uuid autoprovisionSamlUser idp buid uref + validateEmailIfExists buid uref pure buid Logger.log Logger.Debug ("granting sso login for " <> show uid) diff --git a/services/spar/src/Spar/Scim/User.hs b/services/spar/src/Spar/Scim/User.hs index 4b9c97b7ac..cf7642d65d 100644 --- a/services/spar/src/Spar/Scim/User.hs +++ b/services/spar/src/Spar/Scim/User.hs @@ -64,7 +64,8 @@ import Network.URI (URI, parseURI) import Polysemy import Polysemy.Input import qualified SAML2.WebSSO as SAML -import Spar.App (getUserByUrefUnsafe, getUserIdByScimExternalId, validateEmail, validateEmailIfExists) +import Spar.App (getUserByUrefUnsafe, getUserIdByScimExternalId) +import qualified Spar.App import qualified Spar.Intra.BrigApp as Brig import Spar.Scim.Auth () import Spar.Scim.Types (normalizeLikeStored) @@ -481,11 +482,7 @@ createValidScimUser tokeninfo@ScimTokenInfo {stiTeam} vsu@(ST.ValidScimUser veid createValidScimUserSpar stiTeam buid storedUser veid -- If applicable, trigger email validation procedure on brig. - lift $ - ST.runValidExternalIdEither - (validateEmailIfExists buid) - (\_ -> pure () {- nothing to do; user is sent an invitation that validates the address implicitly -}) - veid + lift $ Spar.App.validateEmail (Just stiTeam) buid `mapM_` (veidEmail veid) -- TODO: suspension via scim is brittle, and may leave active users behind: if we don't -- reach the following line due to a crash, the user will be active. From e67cc53619b034ff0595527401f36709cfea6431 Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Tue, 11 Oct 2022 12:28:43 +0200 Subject: [PATCH 2/4] More hints in case of compiler errors. --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c14b958194..48b6c3bf94 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,10 @@ clean: .PHONY: clean-hint clean-hint: @echo -e "\n\n\n>>> PSA: if you get errors that are hard to explain," - @echo -e ">>> try 'make full-clean' and run your command again." - @echo -e ">>> see https://github.com/wireapp/wire-server/blob/develop/docs/developer/building.md#linker-errors-while-compiling\n\n\n" + @echo -e ">>> try 'git submodule update --init --recursive' and 'make full-clean' and run your command again." + @echo -e ">>> see https://github.com/wireapp/wire-server/blob/develop/docs/developer/building.md#linker-errors-while-compiling" + @echo -e ">>> to never have to remember submodules again, try `git config --global submodule.recurse true`" + @echo -e "\n\n\n" .PHONY: cabal.project.local cabal.project.local: From fdb94b343d6fe6689e75be7257f76b98ab65d47e Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Mon, 24 Oct 2022 14:15:28 +0200 Subject: [PATCH 3/4] hlint. --- services/spar/src/Spar/Scim/User.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/spar/src/Spar/Scim/User.hs b/services/spar/src/Spar/Scim/User.hs index cf7642d65d..90624de177 100644 --- a/services/spar/src/Spar/Scim/User.hs +++ b/services/spar/src/Spar/Scim/User.hs @@ -482,7 +482,7 @@ createValidScimUser tokeninfo@ScimTokenInfo {stiTeam} vsu@(ST.ValidScimUser veid createValidScimUserSpar stiTeam buid storedUser veid -- If applicable, trigger email validation procedure on brig. - lift $ Spar.App.validateEmail (Just stiTeam) buid `mapM_` (veidEmail veid) + lift $ Spar.App.validateEmail (Just stiTeam) buid `mapM_` veidEmail veid -- TODO: suspension via scim is brittle, and may leave active users behind: if we don't -- reach the following line due to a crash, the user will be active. From 672b7c50d2e2af80f6b4ba0335aedf5f2f6183ff Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Mon, 24 Oct 2022 21:14:10 +0200 Subject: [PATCH 4/4] Make `make full-clean` fuller. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index c2909ef8e4..a607d23bfe 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,8 @@ ifdef CABAL_DIR else rm -rf ~/.cabal/store endif + rm -rf ./dist-newbuild ./.env + direnv reload .PHONY: clean clean: