Resources are accessible entities within your application. Each resource has a unique identifier and metadata that policies can use for access control decisions. Resource policies are associated by membership in a Resource Group and are evaluated during Phase 3 (Resource Phase) of Policy Conjunction.
Resources in the PolicyEngine are characterized by:
Resources are identified using Manetu Resource Notation (MRN), a universal identifier scheme used throughout the PolicyEngine:
mrn:<type>:<namespace>:<class>:<instance>
Example resource MRNs:
| MRN | Description |
|---|---|
mrn:vault:acme.com:secret:api-key | A secret in the vault |
mrn:data:acme.com:document:report-q4 | A document |
mrn:app:myservice:user:12345 | A user in an application |
See the MRN documentation for complete details on the MRN format and usage patterns.
Every resource has an owner - an MRN reference to an identity:
{
"resource": {
"id": "mrn:app:data:document:123",
"owner": "user@example.com"
}
}
Use ownership in policies:
package authz
default allow = false
# Owner has full access
allow {
input.principal.sub == input.resource.owner
}
Classification is a security rating:
| Level | Value | Description |
|---|---|---|
LOW | 1 | Public data |
MODERATE | 2 | Internal data |
HIGH | 3 | Confidential data |
MAXIMUM | 4 | Top secret data |
UNASSIGNED | 5 | Not yet classified |
Use classification with clearance:
package authz
default allow = false
ratings := {"LOW": 1, "MODERATE": 2, "HIGH": 3, "MAXIMUM": 4}
# Grant if clearance >= classification
allow {
ratings[input.principal.mclearance] >= ratings[input.resource.classification]
}
Every resource belongs to a Resource Group that determines which policies apply:
{
"resource": {
"id": "mrn:app:data:item:456",
"group": "mrn:iam:resource-group:sensitive-data"
}
}
Resource groups associate policies with sets of resources:
spec:
resource-groups:
- mrn: "mrn:iam:resource-group:public"
name: public
description: "Publicly accessible resources"
policy: "mrn:iam:policy:allow-all"
- mrn: "mrn:iam:resource-group:internal"
name: internal
description: "Internal resources requiring authentication"
default: true # Default group for new resources
policy: "mrn:iam:policy:authenticated-only"
- mrn: "mrn:iam:resource-group:sensitive"
name: sensitive
description: "Sensitive resources with strict access"
policy: "mrn:iam:policy:clearance-required"
Starting with v1alpha4, you can use the resources section to route resources to groups based on MRN patterns:
spec:
resources:
- name: sensitive-data
description: "Route sensitive data to restricted group"
selector:
- "mrn:data:sensitive:.*"
- "mrn:secret:.*"
group: "mrn:iam:resource-group:sensitive"
annotations:
- name: classification
value: "\"HIGH\""
:::note[Multiple Selectors]
When a resource entry contains multiple selectors, they have an OR relationship. The resource matches if any of its selectors match. In the example above, sensitive-data matches resources with MRNs matching either mrn:data:sensitive:.* OR mrn:secret:.*. This OR behavior applies uniformly to all selector-based entities (operations, resources, and mappers).
:::
When a resource MRN is resolved:
resources selector matches the MRNSee Resource Resolution and Resources Schema Reference for more information.
Annotations are custom key-value pairs:
{
"resource": {
"id": "mrn:app:data:report:monthly",
"annotations": {
"department": "finance",
"retention": "7years",
"pii": true
}
}
}
Use annotations in policies:
package authz
default allow = false
# Only the finance department can access finance resources
allow {
input.resource.annotations.department == "finance"
input.principal.mannotations.department == "finance"
}
# PII data requires special handling
allow {
not input.resource.annotations.pii
}
allow {
input.resource.annotations.pii
input.principal.mroles[_] == "mrn:iam:role:pii-handler"
}
Resources appear in the PORC expression:
{
"principal": { ... },
"operation": "vault:secret:read",
"resource": {
"id": "mrn:vault:acme:secret:api-key",
"owner": "admin@acme.com",
"group": "mrn:iam:resource-group:secrets",
"classification": "HIGH",
"annotations": {
"environment": "production",
"expires": "2024-12-31"
}
},
"context": { ... }
}
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |