Available only in midPoint 3.6 and later.
Radio button roles is a set of roles where only one role can be assigned to a user at any specific time. When a role from the set is assigned to a user then any other role that was assigned before is automatically unassigned. It works like an radio button: only one button from the set may be "pressed" at any moment. This is a very convenient configuration for application roles that work on the same single-value attribute or which represent conflicting configurations for the same feature. A typical example is a configuration of limits or quotas, let's say we have roles for 10GB quota, 100GB quota and 500GB quota. We want only one of them to be assigned at a time.
This configuration is based on three midPoint mechanisms:
- Policy Rules that implement (almost) ordinary role exclusion.
- The "prune" policy action.
- Clever use of metarole to define the radio button class.
First step is to define exclusion for all the individual "button" roles. This is easy to do with policy rules. However, let's define it in a meta-role that will define the whole "radio button panel". Like this:
Then define each individual "button" role like this:
And that's it. This is how it works:
The metarole has inducements with policy rules. This means that every indivudual quota role (the "button") will receive these policy rules as if they were place in the assignments inside these quota roles. But the metarole allows us to keep this list in one place rather than copy it to all the roles.
The policy rules exclude all the other quota roles (in fact it also exclude the role that contain the rule itself, but as it does not make sense for a role to exclude itself this rule is ignored). Therefore if any quota role is assigned to a user that already has any other quota role then there is a role exclusion conflict. However, the action specified to resolve that conflict is not enforce, therefore there is no error. The action is prune. This means that midPoint will automatically unassign all conflicting roles that the user has. And this is the very mechanism that "switches off" all the other "radio buttons". And at the end of the operation only one quota role remains assigned to the user.