[keycloak-dev] Assign existing roles to clients using a realm json file

Hector Fernandez hfernand at redhat.com
Wed Jun 21 08:19:22 EDT 2017


Hi guys,

We want to assign roles to existing clients whenever we import the realm
json file. I tried several ways and checked your code looking for potential
json elements without any success.


I tried to define them using clientScopeMappings but it seems to be ignored:
```
"clientScopeMappings": {
        "realm-management": [
            {
                "client": "hector-online-platform",
                "roles": ["view-users"]
            },
            {
                "client": "hector-online-platform",
                "roles": ["manage-authorization"]
            }
        ],
        "broker": [
            {
                "client": "hector-online-platform",
                "roles": ["read-token"]
            }
        ]
      }
```

I even tried to use the client element from the roles section in the realm.
But it fails whenever a role exists how it happens with the read-token.

```
"roles": {
   "client": {
      "broker": { "name": "read-token"},
       ...
    }
```

In other words, we want to emulate what we do via admin console -- Clients
-> Choose a client --> Service Account Roles --> Choose a client then
assign a role like for broker the role read-token.


-- 
*<hector/>*


More information about the keycloak-dev mailing list