Skip to content
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

Towards getting scim production-ready #559

Merged
merged 67 commits into from
Jan 29, 2019
Merged

Conversation

fisx
Copy link
Contributor

@fisx fisx commented Dec 27, 2018

No description provided.

@JiangJiabao

This comment has been minimized.

@JiangJiabao

This comment has been minimized.

@fisx fisx changed the title [WIP] towards getting scim production-ready Towards getting scim production-ready Jan 8, 2019
@neongreen neongreen changed the title [WIP] Towards getting scim production-ready Towards getting scim production-ready Jan 24, 2019
--
-- NB: we can add optional columns in the future and extract parts of the json blob should the need
-- arise. For instance, if we want to support different versions of SCIM, we could extract
-- 'SCIM.User.schemas' and, throw an exception if the list of values is not supported, and store it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCIM.User.schemas is no longer a part of User, though it's still present in JSON.

@@ -120,24 +120,26 @@ apiScim = hoistScim (toServant (Scim.siteServer configuration))
----------------------------------------------------------------------------
-- UserDB

-- | Retrieve 'IdP' from 'ScimTokenInfo' and call 'validateSCIMUser''.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here, only the renaming.


-- | Map the SCIM data on the spar and brig schemata, and throw errors if
-- the SCIM data does not comply with the standard / our constraints.
-- See also: 'ValidSCIMUser'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment has been extended.

-- also ignore this model. Leaving @name@ empty will prevent the confusion that
-- might appear when somebody tries to set @name@ to some value and the
-- @displayName@ won't be affected by that change.
validateScimUser'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes again, just renaming.

SCIM.badRequest SCIM.InvalidValue (Just "userName is not compliant")
Scim.badRequest Scim.InvalidValue (Just "userName is not compliant")

-- See this function's documentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prohibit emails and phone numbers.

let userid = scimUserId storedUser
putUser_ (Just tok) (Just userid) user' (env ^. teSpar)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No logic changes.

muserid' <- runSparCass $ Data.getUser (vuser' ^. vsuSAMLUserRef)
liftIO $ do
muserid' `shouldBe` Just userid

it "maps ValidSCIMUser to Brig.User completely and correctly (including 'SAML.UserRef')." $ do
-- See validateScimUser' for why we don't allow this
it "doesn't allow setting emails or phone numbers" $ do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is new. Git mixed it up quite a bit so you might just want to read the two tests without the diff: https://github.com/wireapp/wire-server/blob/fisx-resolve-scim-todos/services/spar/test-integration/Test/Spar/ScimSpec.hs#L225-L253.

@@ -216,10 +273,6 @@ specUsers = describe "operations with users" $ do
it "sets the 'deleted' flag in brig, and does nothing otherwise." $ do
pendingWith "really? how do we destroy the data then, and when?"

describe "GET /Meta" $ do -- TODO: is that the end-point? it's about the 'getMeta' method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no GET /Meta.

suffix <- cs <$> replicateM 5 (getRandomR ('0', '9'))
emails <- replicateM 3 randomSCIMEmail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No emails because no emails.

@@ -0,0 +1,82 @@
{-# LANGUAGE DataKinds #-}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here but Git thinks the file is new. I can't blame it.

-- __Emails and phone numbers:__ we prohibit emails and phone numbers for now,
-- because we'd like to ensure that only verified emails and phone numbers end
-- up in our database, and implementing verification requires design decisions
-- that we haven't made yet.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an issue here if we want to support email as the SAML subjectID, but we don't allow to store it. This should at least be mentioned here, and reject it here with a helpful error message, but we can resolve it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, never mind the link i just gave. scim should know how to create a valid SubjectID, and if that even can be configured, then setting it to "email" is just not an option for now. so the error happens either in scim setup, or setup doesn't talk about this and there is only one way of computing UserRef from the scim schema.

Then we may still want to have a way to turn off implicit user creation.

then pure Nothing
else pure scimuser
mbBrigUser <- lift (Intra.Brig.getUser uid)
if isJust mbBrigUser && (userTeam =<< mbBrigUser) == Just stiTeam
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the isJust is redundant, but if you want to keep it for readability that's fine, too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I want to keep it for readability.

@neongreen neongreen merged commit f78d5cf into develop Jan 29, 2019
@neongreen neongreen deleted the fisx-resolve-scim-todos branch January 29, 2019 17:30
This was referenced Feb 14, 2019
@neongreen neongreen mentioned this pull request Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants