Hi there Z!
Well, in my opinion, the answers to these questions can take into account a few concepts.
Using web search engines, I suggest two of them:
"Realm roles are defined at the realm level and can be used across all client applications within that realm, typically for global permissions. Client roles, on the other hand, are specific to individual client applications and define access permissions unique to those applications."
"Realm Role: It is a global role, belonging to that specific realm. You can access it from any client and map to any user. Ex Role: 'Global Admin, Admin'
Client Role: It is a role which belongs only to that specific client. You cannot access that role from a different client. You can only map it to the Users from that client. Ex Roles: 'Employee, Customer'
Composite Role: It is a role that has one or more roles (realm or client ones) associated to it."
Also, I'd like to mention the reference in the Keycloak book, that point:
"Keycloak also provides the concept of composite roles, a special type of role that chains other roles,
where a user granted a composite role is automatically granted any role in this chain (a regular
role or even another composite role). Although it is a powerful and unique feature that Keycloak
has, you should use it carefully to avoid performance issues – such as when chaining multiple
composite roles – as well as manageability issues due to the proliferation of roles in your system
and the granularity of the permissions associated with them. As a recommendation, if you need
to grant multiple roles to your users, you should consider using groups and assigning roles to
these groups. This is a more natural permission model than using composite roles."
Keycloak - Identity and Access Management for Modern Applications: Harness the power of Keycloak, OpenID Connect, and OAuth 2.0 to secure applications 2nd Edition
- Chapter 8 Authorization Strategies, page 136