Brandon Choe
10/29/2024, 2:05 AMworkflow_sharer
derived role that's separate from workflow_owner
. while I think this would work, I'm wondering if this is a sign that our current approach is not going to be the best approach for us in the future if we continue to need new granular access controls based on things like org settings.
for #2, it seems like it would make sense that our product simply doesn't allow users of an org with external sharing disabled to set publicRole
at all. it makes sense to me that this doesn't need to be a policy-level catch. does that make sense?
I've included parts of our resource and role files in the thread.Brandon Choe
10/29/2024, 2:05 AMapiVersion: api.cerbos.dev/v1
resourcePolicy:
version: default
resource: workflow
importDerivedRoles:
- workflow_derived_roles
rules:
- derivedRoles: ["workflow_owner"]
actions:
["DELETE_WORKFLOW", "EDIT_WORKFLOW", "SHARE_WORKFLOW"]
effect: EFFECT_ALLOW
- derivedRoles: ["workflow_editor"]
actions: ["EDIT_WORKFLOW"]
effect: EFFECT_ALLOW
apiVersion: api.cerbos.dev/v1
derivedRoles:
name: workflow_derived_roles
variables:
import:
- common_variables
local:
workflowCreatorOrgId: R.attr.creator.orgId
workflowPublicRole: R.attr.publicRole
workflowOrgRole: R.attr.orgRole
userRoles: P.attr.userRoles
definitions:
- name: workflow_owner
parentRoles: ["user"]
condition:
match:
any:
of:
# publicRole is set to OWNER
- expr: V.workflowPublicRole == V.WORKFLOW_ROLE_OWNER
# User is the creator of the workflow
- expr: P.id == R.attr.creator.id
# User is in the same org as the workflow creator and orgRole is set to OWNER
- expr: >
P.attr.orgId == V.workflowCreatorOrgId
&& V.workflowOrgRole == V.WORKFLOW_ROLE_OWNER
# User has OWNER WorkflowUserRole
- expr: >
V.userRoles.exists(userRole,
userRole.role == V.WORKFLOW_ROLE_OWNER && userRole.workflowId == R.id
)
- name: workflow_editor
parentRoles: ["user"]
condition:
match:
any:
of:
# publicRole is set to EDITOR
- expr: V.workflowPublicRole == V.WORKFLOW_ROLE_EDITOR
# User is in the same org as the workflow creator and orgRole is set to EDITOR
- expr: >
P.attr.orgId == V.workflowCreatorOrgId
&& V.workflowOrgRole == V.WORKFLOW_ROLE_EDITOR
# User has EDITOR WorkflowUserRole
- expr: >
V.userRoles.exists(userRole,
userRole.role == V.WORKFLOW_ROLE_EDITOR && userRole.workflowId == R.id
)
Andrew Haines (Cerbos)
Brandon Choe
10/30/2024, 12:12 AMAndrew Haines (Cerbos)