Allow auditors to read the organization context
Auditors could not see the Context page in the console because AuditorPolicy was missing core:organization-context:get. Grant the read action (mirroring ViewerPolicy) so the sidebar item appears and the context resolver succeeds for auditors. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -133,6 +133,8 @@ var AuditorPolicy = policy.NewPolicy(
|
||||
ActionOrganizationGetHorizontalLogoUrl,
|
||||
).WithSID("org-read-access").When(organizationCondition),
|
||||
|
||||
policy.Allow(ActionOrganizationContextGet).WithSID("organization-context-read").When(organizationCondition),
|
||||
|
||||
policy.Allow(
|
||||
ActionThirdPartyGet, ActionThirdPartyList,
|
||||
ActionThirdPartyContactGet, ActionThirdPartyContactList,
|
||||
|
||||
@@ -73,3 +73,30 @@ func TestAuditorPolicy_ProcessingActivityPageReadAccess(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuditorPolicy_OrganizationContextReadAccess(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
organizationID := gid.New(gid.NewTenantID(), 1)
|
||||
evaluator := policy.NewEvaluator()
|
||||
conditionContext := policy.ConditionContext{
|
||||
Principal: map[string]string{
|
||||
"organization_id": organizationID.String(),
|
||||
},
|
||||
Resource: map[string]string{
|
||||
"organization_id": organizationID.String(),
|
||||
},
|
||||
}
|
||||
|
||||
result := evaluator.Evaluate(
|
||||
policy.AuthorizationRequest{
|
||||
Principal: organizationID,
|
||||
Resource: organizationID,
|
||||
Action: probo.ActionOrganizationContextGet,
|
||||
ConditionContext: conditionContext,
|
||||
},
|
||||
[]*policy.Policy{probo.AuditorPolicy},
|
||||
)
|
||||
|
||||
assert.True(t, result.IsAllowed())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user