I am using WSO2 Identity Server 4.1.0. My requirement is to assign an existing role to a user created in the WSO2 default identity store. I have tried the following:
Create a user with a role assigned to him:
curl -v -k --user admin:admin --data "{"schemas":[],"name":{"familyName":"FN_atest2","givenName":"LN_atest2"},"userName":"atest2","password":"perf","groups":[{"value":"c83dc72c-15c2-40f2-bddd-4acb086b9e17","display":"Employee"}]}" --header "Content-Type:application/json" `https://localhost:9443/wso2/scim/Users`
Update the user after it is created:
curl -v -k --user admin:admin -X PUT --data "{"schemas":[],"name":{"familyName":"FN_atest2","givenName":"LN_atest2"},"userName":"atest2","password":"perf","groups":[{"value":"c83dc72c-15c2-40f2-bddd-4acb086b9e17","display":"FleetPlanner"}]}" --header "Content-Type:application/json" `https://localhost:9443/wso2/scim/Users/17ebb35d-62af-4cd3-b440-21bcf80714fc`
Neither one of the above assigns the user to the "FleetPlanner" role. How do I assign an existing role to a newly created or an existing WSO2 IS user?
Use PATCH operation:
Nodejs Sample code for SCIM2 (WSO2 Identity server 5.6):
}
Only drawback of this API is that, it returns array containing all members of that group after success. Not optimized if group has thousands or millions of users.
I assume you have the SCIM Id for the role and it is 'c83dc72c-15c2-40f2-bffffd-4acb086b9e17'. And user store is configured properly so the user and role is in the same user store.
If the above conditions are true, you can do the following to achieve the task.
For example,
For more details please check the below link [1] in order to get a clear idea on how you can use PUT to update the role/ group.
[1] http://hasini-gunasinghe.blogspot.com/2012/11/wso2-identity-server-as-scim-service.html