Custom Permissions
MetalSoft’s ABAC (Attribute-Based Access control) system allows complex, custom rules based on CASL conditions, custom fields etc.
Every operation that MetalSoft performs is filtered via a process that checks that the logged-in User has the permission to perform a particular Action against a particular Subject (such as an Infrastructure or a Server). Users are assigned a Role that includes a list of Permissions both built-in or custom. For most situations, the built-in permissions are sufficient. For more complex situations custom permissions might be required.
Creating a custom permission
Section titled “Creating a custom permission”To Create a custom permission using the admin UI perform the following:
- Go to Users & Permissions > Permissions
- Add Permission
- Fill in the details of the permission as per below
- Click add permission
- Go to the Roles tab
- Add edit on an existing role or Add Custom Role
- Check the checkbox next to the newly created permission at the bottom.
Permission Criteria
Section titled “Permission Criteria”The Conditions uses the CASL convention. These conditions have 3 parameters:
-
Action One of:
- All actions
- Create
- List
- Read
- Update
- Delete
- Deploy
- Manage
-
Subject This is the subject of an action, typically an object type such as an
Infrastructure. -
Conditions
Conditions are a JSON using the CASL mechanism. The following examples use the “Infrastructure” Subject:
Test that the infrastructure has the id 120
{ "id": 120}Test User field userId equality with a Subject field:
{ "userIdOwner": "{{userId}}"}Test the infrastructure’s status value one of active and ordered`
{ "serviceStatus": "{ $in: ['active', 'ordered'] }"}Multiple conditions
{ "createdAt": "{ $lte: new Date() }", "status": "{ $in: ['active', 'ordered'] }"}Possible operations list
$eqand$neobject value should equal specified value.$nemeansnot $eq$ltand$lteobject value should be less than specified value. Can be used for Dates, numbers and strings.$lteis a combination of$ltand$eq, so it’s an inclusive check.$gtand$gteobject value should be greater than specified value. Can be used for Dates, numbers and strings.$gteis a combination of$gtand$eq, so it’s an inclusive check.$inand$ninChecks that object’s property is of the specified array values. Can be used for single value and for arrays as well. If object’s property is an array it checks for intersection.$ninmeans not$in$allChecks that object’s property should contain all elements from the specified array. Can be used for arrays only.$sizeChecks that array length equals to specified value. Can be used for arrays only$regexAllows to test object’s property value using regular expression. Can be used for strings only$existsChecks that property exists in the object.$elemMatchChecks nested elements shape. Use$elemMatchoperator to specify multiple criteria on the elements of an array such that at least one array element satisfies all the specified criteria. If you specify only a single condition in the$elemMatchexpression,$elemMatchis not necessary. See Specify Multiple Conditions for Array Elements for details.
Refer to this resource for more details: Conditions in Depth
Getting the list of fields that can be used for the Subject
Section titled “Getting the list of fields that can be used for the Subject”To get the list of fields available for each Subject, refer to the API documentation of your environment (accessible at https://your-env-hostname/api/v2/swagger) for an up-to-date list of possible Objects (scroll towards the bottom).
User-related fields
Section titled “User-related fields”The following are custom fields that can be used that map to the logged-in user’s properties:
{{userId}}- Logged-in user’s ID{{accountId}}- Logged-in user’s account ID
Fields
Section titled “Fields”This field in the form allows to restrict access to a certain list of fields rather than all fields. This can be used in conjunction with the Conditions field or as stand-alone.
If none is entered, all fields can be changed by the User (Principal) operating on the Subject.