【问题标题】:Keycloak RestAPI: Assign client role to groupKeycloak RestAPI:将客户端角色分配给组
【发布时间】:2021-01-03 16:53:32
【问题描述】:

我试过这个: url="https://{localhost}/auth/admin/realms/{realm_name}/groups/{group_id}/role-mappings" payload=[{"id":"role_id","name":"Role_name","composite":"false","clientRole":"true","containerId":"client_id"}]

但是,它不起作用,我认为这可能与错误的有效载荷有关 有什么想法请

【问题讨论】:

    标签: keycloak rest


    【解决方案1】:

    格式正确,但您确保客户端具有可用的有效负载角色。 这是“Hr”组添加“RomoteApp”客户端“tile limit”角色的示例。

    在 Keycloak UI 中,@Client > RemoteApp > Roles

    角色名称

    time limit
    

    组 > 小时 客户端角色:RemoteApp 可用角色:时间限制 分配的角色:尚未包括“时间限制”

    邮递员的 POST 推荐 - 由于 stan 溢出级别低,我还不能附加图片 http://127.0.0.1:8080/auth/admin/realms/Test-realm/groups/9efef6bf-7edb-496e-bc0d-a8d4f5f4e3a9/role-mappings/clients/60a19179-f244-42f8-9950-04f2119a4e5b?client=RemoteApp&id=60a19179-f244-42f8-9950-04f2119a4e5b&realm=Test-realm

    在带有行 JSON 选项的邮递员正文中( Content-Type : application/json )

    [
        {
            "id": "e17f9f7f-62dc-4998-b058-49b845ff5cef",
            "name": "time limit",
            "description": "time limit",
            "composite": false,
            "clientRole": true,
            "containerId": "60a19179-f244-42f8-9950-04f2119a4e5b"
        }
    ]
    

    组列表

       {
            "id": "9efef6bf-7edb-496e-bc0d-a8d4f5f4e3a9",
            "name": "hr",
            "path": "/hr",
            "subGroups": []
        }
    

    客户名单

        {
            "id": "60a19179-f244-42f8-9950-04f2119a4e5b",
            "clientId": "RemoteApp",
         ...
        }
    

    也不记得令牌端点调用的访问令牌 w/grant_type 是password

    http://127.0.0.1:8080/auth/realms/Test-realm/protocol/openid-connect/token
    

    【讨论】:

      【解决方案2】:

      我们可以使用 python-keycloak 库:https://pypi.org/project/python-keycloak/ 有一个函数:assign_group_client_roles

      【讨论】:

        猜你喜欢
        • 2021-10-27
        • 2017-09-12
        • 2017-08-30
        • 1970-01-01
        • 2018-09-23
        • 1970-01-01
        • 2019-10-19
        • 2018-03-30
        • 1970-01-01
        相关资源
        最近更新 更多