ldap-scim-bridge 0.4 → 0.5
raw patch · 5 files changed
+30/−11 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- README.md +3/−2
- examples/wire-server/run.sh +13/−3
- ldap-scim-bridge.cabal +1/−1
- src/LdapScimBridge.hs +9/−5
CHANGELOG.md view
@@ -3,6 +3,10 @@ `ldap-scim-bridge` uses [PVP][1]-compatible versioning. The changelog is available [on GitHub][2]. +## 0.5++- Various small fixes (#15)+ ## 0.4 - Filter for arbitrary LDAP attributes (#16)
README.md view
@@ -11,8 +11,9 @@ ## intro This is a small command line tool to pull data from an LDAP server and-push it to a SCIM peer. It supports only fields `externalId`,-`userName`, `emails`, in the `User` schema and no `Group`s.+push it to a SCIM peer. It supports fields `externalId`,+`userName`, `displayName`, `emails`, in the `User` schema. It may not+support any other fields, and it does not support scim `Group`s. If you extend this to other fields, groups, or other use cases and setups, we would highly appreciate pull requests, tickets, or emails (no matter how half-baked).
examples/wire-server/run.sh view
@@ -38,9 +38,17 @@ } function clear() {- # TODO: this both fails independently; I have not investigated.- sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// DN "ou=People,dc=nodomain"- sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// DN "cn=john,ou=People,dc=nodomain"+ # TODO: sometimes we want to know if this fails, but only if it's+ # other errors than "already exists". or maybe we can test for+ # existence before we attemp to delete, and then fail on all+ # remaining errors?+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "cn=notcreated,ou=NoPeople,dc=nodomain" || true+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "cn=notcreated,ou=DeletedPeople,dc=nodomain" || true+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "cn=uses123email,ou=People,dc=nodomain" || true+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "cn=uses123email,ou=DeletedPeople,dc=nodomain" || true+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "ou=People,dc=nodomain" || true+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "ou=DeletedPeople,dc=nodomain" || true+ sudo ldapdelete -D "cn=admin,dc=nodomain" -w geheim -H ldapi:/// "ou=NoPeople,dc=nodomain" || true } function scaffolding1() {@@ -104,6 +112,8 @@ # ---------------------------------------------------------------------- # main++clear scaffolding_spar echo WIRE_USERID: $WIRE_USERID
ldap-scim-bridge.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: ldap-scim-bridge-version: 0.4+version: 0.5 synopsis: See README for synopsis description: See README for description homepage: https://github.com/fisx/ldap-scim-bridge
src/LdapScimBridge.hs view
@@ -209,7 +209,7 @@ instance Aeson.FromJSON Mapping where parseJSON = Aeson.withObject "Mapping" $ \obj -> do- fdisplayName <- obj Aeson..: "displayName"+ mfdisplayName <- obj Aeson..:? "displayName" fuserName <- obj Aeson..: "userName" fexternalId <- obj Aeson..: "externalId" mfemail <- obj Aeson..:? "email"@@ -220,7 +220,7 @@ go mp (k, b) = Map.alter (Just . maybe [b] (b :)) k mp pure . Mapping . listToMap . catMaybes $- [ Just (fdisplayName, mapDisplayName fdisplayName),+ [ (\fdisplayName -> (fdisplayName, mapDisplayName fdisplayName)) <$> mfdisplayName, Just (fuserName, mapUserName fuserName), Just (fexternalId, mapExternalId fexternalId), (\femail -> (femail, mapEmail femail)) <$> mfemail@@ -246,6 +246,7 @@ [val] -> Right $ \usr -> usr {Scim.externalId = Just val} bad -> Left $ WrongNumberOfAttrValues ldapFieldName "1" (Prelude.length bad) + mapEmail :: Text -> FieldMapping mapEmail ldapFieldName = FieldMapping "emails" $ \case [] -> Right id@@ -274,9 +275,12 @@ listLdapUsers :: LdapConf -> LdapSearch -> LdapResult [SearchEntry] listLdapUsers conf searchConf = Ldap.with (ldapHost conf) (ldapPort conf) $ \l -> do Ldap.bind l (ldapDn conf) (ldapPassword conf)- let fltr :: Filter = ldapObjectClassFilter . ldapSearchObjectClass $ searchConf- allfltr :: Filter = And (fltr :| (ldapFilterAttrToFilter <$> ldapSearchExtra searchConf))- Ldap.search l (ldapSearchBase searchConf) mempty allfltr mempty+ let fltr :: Filter =+ And+ ( ldapObjectClassFilter (ldapSearchObjectClass searchConf)+ :| (ldapFilterAttrToFilter <$> ldapSearchExtra searchConf)+ )+ Ldap.search l (ldapSearchBase searchConf) mempty fltr mempty type User = Scim.User ScimTag