This guide will walk you through creating your first PolicyDomain and testing policy decisions.
In this quick start, you will:
A PolicyDomain is a YAML file that bundles together all the policy-related artifacts for a specific domain or service:
Create a file called my-domain.yml:
apiVersion: iamlite.manetu.io/v1beta1
kind: PolicyDomain
metadata:
name: my-first-domain
spec:
policies:
- mrn: &operation-default "mrn:iam:policy:operation-default"
name: operation-default
description: "Defers to identity and resource phases"
rego: |
package authz
default allow = 0 # Tri-level: negative=DENY, 0=GRANT, positive=GRANT Override
- mrn: &allow-all "mrn:iam:policy:allow-all"
name: allow-all
description: "Allows all authenticated requests"
rego: |
package authz
default allow = false
allow {
input.principal != {}
}
- mrn: &deny-all "mrn:iam:policy:deny-all"
name: deny-all
description: "Denies all requests"
rego: |
package authz
default allow = false
roles:
- mrn: "mrn:iam:role:admin"
name: admin
description: "Administrator role with full access"
policy: *allow-all
- mrn: "mrn:iam:role:guest"
name: guest
description: "Guest role with no access"
policy: *deny-all
resource-groups:
- mrn: "mrn:iam:resource-group:default"
name: default
description: "Default resource group"
default: true
policy: *allow-all
operations:
- name: api
selector:
- ".*"
policy: *operation-default
Use the lint command to validate your PolicyDomain:
mpe lint -f my-domain.yml
If everything is valid, you'll see:
Linting YAML files...
✓ my-domain.yml: Valid YAML
✓ my-domain.yml: Valid Rego in policy 'operation-default'
✓ my-domain.yml: Valid Rego in policy 'allow-all'
✓ my-domain.yml: Valid Rego in policy 'deny-all'
---
All checks passed: 1 file(s) validated successfully
See Testing Policies for detailed testing instructions.
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 |