@@ -47,7 +47,8 @@ import Brig.Types.User (ManagedBy (..), Name (..), User (..))
47
47
import qualified Brig.Types.User as BT
48
48
import qualified Control.Applicative as Applicative (empty )
49
49
import Control.Lens (view , (^.) )
50
- import Control.Monad.Except (MonadError , throwError )
50
+ import Control.Monad.Error.Class (MonadError )
51
+ import Control.Monad.Except (runExceptT , throwError )
51
52
import Control.Monad.Trans.Except (mapExceptT )
52
53
import Control.Monad.Trans.Maybe (MaybeT (MaybeT ), runMaybeT )
53
54
import Crypto.Hash (Digest , SHA256 , hashlazy )
@@ -765,7 +766,13 @@ scimFindUserByHandle mIdpConfig stiTeam hndl = do
765
766
-- successful authentication with their SAML credentials.
766
767
scimFindUserByEmail :: Maybe IdP -> TeamId -> Text -> MaybeT (Scim. ScimHandler Spar ) (Scim. StoredUser ST. SparTag )
767
768
scimFindUserByEmail mIdpConfig stiTeam email = do
768
- veid <- mkValidExternalId mIdpConfig (pure email)
769
+ -- Azure has been observed to search for externalIds that are not emails, even if the
770
+ -- mapping is set up like it should be. This is a problem: if there is no SAML IdP, 'mkValidExternalId'
771
+ -- only supports external IDs that are emails. This is a missing feature / bug in spar tracked in
772
+ -- https://wearezeta.atlassian.net/browse/SQSERVICES-157; once it is fixed, we should go back to
773
+ -- throwing errors returned by 'mkValidExternalId' here, but *not* throw an error if the externalId is
774
+ -- a UUID, or any other text that is valid according to SCIM.
775
+ veid <- MaybeT (either (const Nothing ) Just <$> runExceptT (mkValidExternalId mIdpConfig (pure email)))
769
776
uid <- MaybeT . lift $ ST. runValidExternalId withUref withEmailOnly veid
770
777
brigUser <- MaybeT . lift . Brig. getBrigUserAccount Brig. WithPendingInvitations $ uid
771
778
guard $ userTeam (accountUser brigUser) == Just stiTeam
0 commit comments