Saturday, September 20, 2014

WSO2 Identity Server as a SCIM provider with secondary user store

WSO2 Identity Server [1] ship with embedded LDAP as  primary user store and you can plug any JDBC, LDAP, Active Directory user store as a secondary user store.

If you have primary user store only SCIM commands works as mentioned here [2]. If need to execute those commands for secondary user store follow these steps

Important: you have to put username and group name in following format 
'<user store domain>/username' and remember to use single quotes instead of double quotes.

1. Create User

curl -v -k --user admin:admin --data "{"schemas":[],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":'JDBC/hasinitg',"password":"hasinitg","emails":[{"primary":true,"value":"hasini_home.com","type":"home"},{"value":"hasini_work.com","type":"work"}]}" --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users

Response

{"id":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","schemas":["urn:scim:schemas:core:1.0"],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"JDBC/hasinitg","emails":[{"value":"hasini_home.com","type":"home"},{"value":"hasini_work.com","type":"work"}],"meta":{"lastModified":"2014-09-14T22:20:23","location":"https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63","created":"2014-09-14T22:20:23"}}

2. Get User 

curl -v -k --user admin:admin https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63

Response

{"id":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","schemas":["urn:scim:schemas:core:1.0"],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"JDBC/hasinitg","emails":[{"value":"hasini_work.com","type":"work"},{"value":"hasini_home.com","type":"home"}],"meta":{"lastModified":"2014-09-14T22:20:23","created":"2014-09-14T22:20:23","location":"https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63"}}

3. List Users

curl -v -k --user admin:admin https://localhost:9443/wso2/scim/Users

Response

{"schemas":["urn:scim:schemas:core:1.0"],"totalResults":1,"Resources":[{"id":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"JDBC/hasinitg","emails":[{"value":"hasini_work.com","type":"work"},{"value":"hasini_home.com","type":"home"}],"meta":{"lastModified":"2014-09-14T22:20:23","created":"2014-09-14T22:20:23","location":"https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63"}}]}

4. Update User

curl -v -k --user admin:admin -X PUT -d "{"schemas":[],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":'JDBC/hasinitg',"emails":[{"value":"hasini@wso2.com","type":"work"},{"value":"hasi7786@gmail.com","type":"home"}]}" --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63

Response

{"id":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","schemas":["urn:scim:schemas:core:1.0"],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"JDBC/hasinitg","emails":[{"value":"hasini@wso2.com","type":"work"},{"value":"hasi7786@gmail.com","type":"home"}],"meta":{"lastModified":"2014-09-14T22:38:47","location":"https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63","created":"2014-09-14T22:20:23"},"groups":[{"value":"2d639c4c-78e3-4f83-b12e-9ce23b90eeab","display":"JDBC/engineer"}]}

5. Delete User

curl -v -k --user admin:admin -X DELETE https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63 -H "Accept: application/json"

6. Filter User

curl -v -k --user admin:admin https://localhost:9443/wso2/scim/Users?filter=userNameEqJDBC/hasinitg

Response

{"schemas":["urn:scim:schemas:core:1.0"],"totalResults":1,"Resources":[{"id":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"JDBC/hasinitg","emails":[{"value":"hasini_work.com","type":"work"},{"value":"hasini_home.com","type":"home"}],"meta":{"lastModified":"2014-09-14T22:20:23","created":"2014-09-14T22:20:23","location":"https://localhost:9443/wso2/scim/Users/2f4a6f3a-7a09-4826-9bde-6082c57a9e63"}}]}

7. Create Group

curl -v -k --user admin:admin --data "{"displayName": 'JDBC/engineer',"members": [{"value":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","display": 'JDBC/hasinitg'}]}" --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Groups

Response

{"id":"2d639c4c-78e3-4f83-b12e-9ce23b90eeab","schemas":["urn:scim:schemas:core:1.0"],"displayName":"JDBC/engineer","members":[{"value":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","display":"JDBC/hasinitg"}],"meta":{"lastModified":"2014-09-14T22:33:42","created":"2014-09-14T22:33:42","location":"https://localhost:9443/wso2/scim/Groups/2d639c4c-78e3-4f83-b12e-9ce23b90eeab"}}

8. List Groups

curl -v -k --user admin:admin https://localhost:9443/wso2/scim/Groups

Response

{"schemas":["urn:scim:schemas:core:1.0"],"totalResults":1,"Resources":[{"id":"2d639c4c-78e3-4f83-b12e-9ce23b90eeab","displayName":"JDBC/engineer","members":[{"value":"2f4a6f3a-7a09-4826-9bde-6082c57a9e63","display":"JDBC/hasinitg"}],"meta":{"lastModified":"2014-09-14T22:33:42","created":"2014-09-14T22:33:42","location":"https://localhost:9443/wso2/scim/Groups/2d639c4c-78e3-4f83-b12e-9ce23b90eeab"}}]}


[1] http://wso2.com/products/identity-server/

[2] https://docs.wso2.com/display/IS500/WSO2+Identity+Server+as+a+SCIM+Service+Provider

No comments:

Post a Comment