WSO2身份服务器 - 如何将现有角色分配给WSO2 IS用户?

问题描述:

我使用的是WSO2 Identity Server 4.1.0。我的要求是为在WSO2默认身份存储中创建的用户分配现有角色。我已尝试以下操作:

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:


  1. 创建一个角色分配给他的用户:

  1. 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`
    


  • 上述任一个都不会将用户分配给FleetPlanner角色。
    如何将现有角色分配给新创建的或现有的WSO2 IS用户?

    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?

    我假设你有角色的SCIM Id,它是'c83dc72c-15c2-40f2-bddd-4acb086b9e17'。并且用户存储配置正确,因此用户和角色位于同一用户存储中。

    I assume you have the SCIM Id for the role and it is 'c83dc72c-15c2-40f2-bddd-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.


    1. 使用curl命令创建用户(此处您正在使用SCIM)

    2. 使用用户的SCIM ID使用PUT方法更新组。

    例如,

    curl -v -k --user admin:admin -X PUT -d "{"displayName": 'Engineer' ,"members": [{"value":"334d988a-5e68-4594-8b96-356adeec29f1","display": "venura"}, {"value":"p09okhyt-5e68-4594-8mkj-356ade12we34","display": "testUser"}]}" --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Groups/c83dc72c-15c2-40f2-bddd-4acb086b9e17
    

    更多详情请检查以下链接[1],以便清楚了解如何使用PUT更新角色/组。

    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