Pages

Subscribe:

Ads 468x60px

Thursday, December 18, 2014

Extending SCIM User Schema Of WSO2 Identity Server

In this post we are going to extend the SCIM User Schema Of WSO2 Identity Server and add custom fields.
More details about Extending SCIM User Schema Of WSO2 Identity Server and SCIM User Provisioning With WSO2 Identity Server using these links. [1], [2]. In this sample we are going to add a custom field called dateOfBirth to the schema. Follow the following steps to enable the custom field.
 
1. Enable User Schema Extension by setting the user-schema-extension-enabled value true in /repositiry/conf/provisioning-config.xml
2. Set your Custom User Schema as follows in the /repository/conf/scim-schema-extension.config
=================================================================================
[
{
"attributeURI":"urn:scim:schemas:extension:wso2:1.0:wso2Extension.dateOfBirth",
"attributeName":"dateOfBirth",
"dataType":"string",
"multiValued":"false",
"multiValuedAttributeChildName":"null",
"description":"Date of Birth",
"schemaURI":"urn:scim:schemas:extension:wso2:1.0",
"readOnly":"true",
"required":"true",
"caseExact":"true",
"subAttributes":"null"
},
{
"attributeURI":"urn:scim:schemas:extension:wso2:1.0",
"attributeName":"wso2Extension",
"dataType":"null",
"multiValued":"false",
"multiValuedAttributeChildName":"null",
"description":"SCIM wso2 User Schema Extension",
"schemaURI":"urn:scim:schemas:extension:wso2:1.0",
"readOnly":"false",
"required":"false",
"caseExact":"false",
"subAttributes":"dateOfBirth"
}
]
==================================================================================

3. Start the server and login to the management console.
4. Go to
Home     > Configure     > Claim Management > urn:scim:schemas:core:1.0 > Add New Claim Mapping

File in the Followings
Display Name - dateOfBirth
Description- Date of Birth
Claim Uri - urn:scim:schemas:extension:wso2:1.0:wso2Extension.dateOfBirth
Mapped Attribute (s) - nickName

Here we have mapped to the nickName which is already available.

5. Now you are done with the configurations.

Now execute the following curl commands to add and get the user.

Adding a user
curl -v -k --user admin:admin --data "{"schemas":[],"wso2Extension":{"dateOfBirth":"1987-12-12"},"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"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

Getting a user using the following command
curl -v -k --user admin:admin https://localhost:9443/wso2/scim/Users/[User ID Value]

Will result the following.

{"id":"92851fef-31a8-4c54-b631-616e58a85cc8","wso2Extension":{"dateOfBirth":"1987-12-12"},"schemas":["urn:scim:schemas:core:1.0","urn:scim:schemas:extension:wso2:1.0"],"nickName":"2012-12-12","name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"hasinitg","emails":[{"value":"hasini_work.com","type":"work"},{"value":"hasini_home.com","type":"home"}],"meta":{"lastModified":"2014-12-02T15:29:27","created":"2014-12-02T15:29:27","location":"https://localhost:9443/wso2/scim/Users/92851fef-31a8-4c54-b631-616e58a85cc8"}}


[1]. http://sureshatt.blogspot.com/2013/06/scim-user-provisioning-with-wso2.html
[2]. http://sureshatt.blogspot.com/2013/07/extending-scim-user-schema-of-wso2.html

1 comment: