Search code examples
jsonwso2scimwso2-identity-server

wso2 5.6 identity server SCIM user creation with email and while find the users email is not returning from JSON


While creating a user using SCIM1.1 endpoint with email.

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

Created User response:

{"emails":[{"value":"hasini_home.com"}],"meta":{"created":"2018-09-18T15:43:17","location":"https://localhost:9443/wso2/scim/Users/37f051b2-770c-4915-9a3f-623a7404b2a4","lastModified":"2018-09-18T15:43:17"},"schemas":["urn:scim:schemas:core:1.0"],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"id":"37f051b2-770c-4915-9a3f-623a7404b2a4","userName":"hasinitg_sample"}

Retrieve the USER from SCIM endpoint:

curl -v -k --user admin:admin https://localhost:9443/wso2/scim/Users/37f051b2-770c-4915-9a3f-623a7404b2a4

The response is:

{"meta":{"created":"2018-09-18T15:43:17","location":"https://localhost:9443/wso2/scim/Users/37f051b2-770c-4915-9a3f-623a7404b2a4","lastModified":"2018-09-18T15:43:17"},"schemas":["urn:scim:schemas:core:1.0"],"roles":["Internal/everyone"],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"id":"37f051b2-770c-4915-9a3f-623a7404b2a4","userName":"hasinitg_sample"}

The email is missing here in the response and My-Sql DB as well. Any idea?


Solution

  • The issue seems to be that if you are sending the email as a JSON object, you have to set the type as well. Following debug log is written when we send an email object without the type attribute.

    TID: [-1234] [] [2018-09-19] DEBUG {org.wso2.carbon.identity.scim.common.utils.AttributeMapper} - Type attribute cannot be null for sub attribute: org.wso2.charon.core.attributes.ComplexAttribute@71ebf24c of Complex MultiValuedAttribute: emails. Skip adding as a claim

    Please see the given sample request in the documentation

    {"primary":true,"value":"hasini_home.com","type":"home"}
    

    You can use the following request to simply solve your problem.

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