to seperate access within a single harness instance we use RBAC (roles + resource groups) and OPA to guardrail what users can do based on group membership.
primer: RBAC assignments are made by assigning a role (what actions can a user take) and a resource group (what resources can they act on).
all RBAC assignments should be made on a group and not individual users
roles: what can a user do
create a role which defines the actions a user can take. the above is an example of the FME Manager role which outlines all FME actions a user can take.
resource groups: what resources a user can act on
targeted resources can be all (of a specific type), by tag (only resources with a specific tag), or specific (individually targeted resources).
not all resources support all the above options at minimum "all" will always be an option.
rbac assignment: combining a role and resource group to define what actions a user can take on which resources
when assigning access you must select a role and a resource group, where to result in access you must be allowed actions on a matching resource type
for example, if you give pipeline:edit on all pipelines, the user can edit all pipelines. however if you give pipeline:edit on all feature flags, this will result in no access given.
opa: policy as code
this can come in handy when you need to shore some gaps or missing requirements in your rbac assignements.
a common example of this is when trying to give two different user groups access to a shared reousrce type but not allow them to edit eachothers resource type
example: two independent groups (ci and cd) need access to create/edit templates at the same scope
solution: grant both group template:creat/edit access to all templates at a given scope
then create an OPA policy on templates which is able to evaluate the template being created/edited and the user context of the user performing the action, where we can stop the action if the resource lacks the particular tag that belongs to that group.
package template
import future.keywords.in
required_tags = {"ci", "cd", "db"}
any_required_tag_exists(map) {
some key in required_tags
_ = map[key]
}
# Deny if any template does not have at least one of the required tags
deny[msg] {
not any_required_tag_exists(input.template.tags)
msg = sprintf("Template must have one of required tags: %s", [required_tags])
}
user_in_group(group) {
some i
input.metadata.userGroups[i].identifier == group
}
# Only allow changes to the templates with ci tag by users in the ci group
deny[msg] {
# Define the tags and approved group which can modify them
approved_tag = "ci"
approved_group := "ci"
# If template has tag
_ = input.template.tags[approved_tag]
# If user does not have target group
not user_in_group(approved_group)
# Compose the deny message
msg = sprintf("User %s not in %s group", [input.metadata.user.name, approved_group])
}
# Only allow changes to the templates with cd tag by users in the cd group
deny[msg] {
# Define the tags and approved group which can modify them
approved_tag = "cd"
approved_group := "cd"
# If template has tag
_ = input.template.tags[approved_tag]
# If user does not have target group
not user_in_group(approved_group)
# Compose the deny message
msg = sprintf("User %s not in %s group", [input.metadata.user.name, approved_group])
}
# Only allow changes to the templates with db tag by users in the db group
deny[msg] {
# Define the tags and approved group which can modify them
approved_tag = "db"
approved_group := "db"
# If template has tag
_ = input.template.tags[approved_tag]
# If user does not have target group
not user_in_group(approved_group)
# Compose the deny message
msg = sprintf("User %s not in %s group", [input.metadata.user.name, approved_group])
}you would create a template policy with the above content (adjusting the groups and tags as nessesary) and create a policyset to evaluate templates on save.