MidPoint is very flexible system, especially when it comes to approval and other policies. But the flexibility comes at a cost. Policy definition can be quite complex. Some of this complexity is inherent and cannot really be avoided. But once the policies are created then it should be quite easy to apply them to individual objects such as users and roles. Fortunately, the mechanism of metaroles can be used exactly for this purpose.
The basic idea is to express the policies in a form of metaroles. For example the policy that drives role assignment through an approval will be expressed in "approval by manager" metarole. This metarole will contain all the policy rules necessary to express the approval policy. Those policy rules may be quite complex, but they are all conveniently packed into the metarole. All that remains is to assign the metarole to an object to which it should apply - which is usually a role. So, we end up with a role with an assignment to a another role. And that is what we call metarole. The situation looks like this:
The picture above illustrates application of approval policy to a
Supervisor role. Supervisor is ordinary business or application role. It was perhaps just created. And now we want to apply the usual approval policy to this role. The usual approval policy is specified in the "Approval by manager metarole". This metarole specifies all the necessary policy rules. But those rules are specified inside inducement. Therefore the policy rules do not apply to the role which contains them, i.e. the rules do not apply to the "Approval by manager metarole". Those policy rules will apply to any object that has the metarole assigned. In this case it is the
Supervisor role. The
Supervisor role will be affected by the policy rules.
Approval By Manager
Following metarole contains "manager" approval policy. When this metaroles is applied to ordinary role then the approval policy is applied to that ordinary role. When that ordinary role is assigned to a user, the request is driven through an approval process. In this case the approval will be requested from user's manager. The getManagersOidsExceptUser(...) function from MidPoint Script Library is used to get the manager.
Approval By Approver
Following metarole contains "approver" approval policy. When this metaroles is applied to ordinary role then the approval policy is applied to that ordinary role. When that ordinary role is assigned to a user, the request is driven through an approval process. In this case the approval will be requested from the person that is designated as role approver.
The policy rule above will drive the role through an approval of a role approver. Role approver is determined by examining all the users that have this role assigned with a special-purpose approver relation. Please see the description of the approval mechanism for more details.