wso2scimwso2-identity-server

WSO2is SCIM 2 create new user with custom fields


I can create new users following a sample found it here:

curl -v -k --user admin@tenant1.com@tenant1.com:admin --data '{"schemas":[],"name":{"familyName":"jackson","givenName":"kim"},"phoneNumbers":[{"type":"mobile","value":"9999"}],"addresses":[{"type":"work","streetAddress":"100 Universal City Plaza","locality":"Hollywood","region":"CA","postalCode":"90068","country":"USA","formatted":"100 Universal City Plaza\nHollywood, CA 90068 USA","primary":true},{"type":"home","streetAddress":"456 Hollywood Blvd","locality":"Hollywood","region":"CA","postalCode":"91608","country":"USA","formatted":"456 Hollywood Blvd\nHollywood, CA 91608 USA"}],"userName":"kim@mail.com","password":"kimwso2","nickName":"abc","title":"Operations Chief","urn:ietf:params:scim:schemas:core:2.0:User:streetAddress":"Miami, florida","emails":[{"primary":true,"value":"kim.jackson@gmail.com","type":"home"},{"value":"kim_j@wso2.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/t/tenant1.com/scim2/Users

I want to add support for departments field to a new user.

In claims for urn:ietf:params:scim:schemas:extension:enterprise:2.0:User I have made sure that the claim department exists with the mapping to http://wso2.org/claims

enter image description here

enter image description here

script with department added

curl -v -k --user admin@tenant1.com@tenant1.com:admin --data '{"schemas":[],"name":{"familyName":"jackson","givenName":"kim"},"phoneNumbers":[{"type":"mobile","value":"9999"}],"addresses":[{"type":"work","streetAddress":"100 Universal City Plaza","locality":"Hollywood","region":"CA","postalCode":"90068","country":"USA","formatted":"100 Universal City Plaza\nHollywood, CA 90068 USA","primary":true},{"type":"home","streetAddress":"456 Hollywood Blvd","locality":"Hollywood","region":"CA","postalCode":"91608","country":"USA","formatted":"456 Hollywood Blvd\nHollywood, CA 91608 USA"}],"department":["Accounting","Marketing and Advertising"],"userName":"kim@mail.com","password":"kimwso2","nickName":"abc","title":"bhhhxxs","urn:ietf:params:scim:schemas:core:2.0:User:streetAddress":"bhhhxxs","emails":[{"primary":true,"value":"kim.jackson@gmail.com","type":"home"},{"value":"kim_j@wso2.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/t/tenant1.com/scim2/Users

If I add department field to script, this create but not return when make the request for this user id:

result of curl -v -k --user admin@tenant1.com@tenant1.com:admin https://localhost:9443/t/tenant1.com/scim2/Users/44c7b532-09fe-4530-a199-cf81bff95b3a | jq .

{
    "emails": [{
            "type": "work",
            "value": "kim_j@wso2.com"
        },
        {
            "type": "home",
            "value": "kim.jackson@gmail.com"
        }
    ],
    "addresses": [{
            "type": "work",
            "value": "100 Universal City Plaza\nHollywood, CA 90068 USA"
        },
        {
            "type": "home",
            "value": "456 Hollywood Blvd\nHollywood, CA 91608 USA"
        }
    ],
    "meta": {
        "created": "2020-04-08T12:46:30.549Z",
        "location": "https://localhost:9443/t/tenant1.com/scim2/Users/44c7b532-09fe-4530-a199-cf81bff95b3a",
        "lastModified": "2020-04-08T12:46:30.549Z",
        "resourceType": "User"
    },
    "nickName": "abc",
    "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
    ],
    "roles": [{
        "type": "default",
        "value": "Internal/everyone"
    }],
    "name": {
        "givenName": "kim",
        "familyName": "jackson"
    },
    "id": "44c7b532-09fe-4530-a199-cf81bff95b3a",
    "userName": "kim@mail.com",
    "title": "bhhhxxs",
    "phoneNumbers": [{
        "type": "mobile",
        "value": "9999"
    }]
}

I already read this docs without success: https://is.docs.wso2.com/en/latest/develop/extensible-scim-user-schemas-with-wso2-identity-server/#extensible-scim-user-schemas-with-wso2-identity-server

https://is.docs.wso2.com/en/latest/develop/extending-scim2-user-schemas/#extending-the-scim-20-api

My setup: wso2is 5.10


Solution

  • You can find a sample request to create a user with an extended schema attribute in https://github.com/wso2/docs-is/issues/1556

    The trick is to represent the extended attribute as below in the create request

    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
        "department": [
            "Accounting",
            "Marketing and Advertising"
        ]
    }
    

    Update: By default the urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department is not a multi-valued attribute in the scim2 schema defined in the server. You can make it multi valued by editing the IS_HOME/repository/conf/scim2-schema-extension.config file to make it a multi-valued attribute

    {
    "attributeURI":"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department",
    "attributeName":"department",
    "dataType":"string",
    "multiValued":"true",
    "description":"Identifies the name of a department",
    "required":"false",
    "caseExact":"false",
    "mutability":"readWrite",
    "returned":"default",
    "uniqueness":"none",
    "subAttributes":"null",
    "canonicalValues":[],
    "referenceTypes":[]
    }
    

    Note how the "multiValue" attribute has been updated.