Test a policy safely
There's no report-only mode, so try a new rule in a policy set nothing enforces, ask the realm what it would decide, then move it in.
APIOpenID AuthZEN Authorization API 1.0
A policy decides real calls the moment it’s active in a set an enforcement point reads, and one deny refuses everything it covers. The realm has no report-only mode and no sign-in simulation. What it has is enough to test safely: a test set that no enforcement point reads, and the realm’s decision API, which answers what a set would decide for any caller you describe. This guide writes a rule in a test set, checks the answers, then moves it into the real set.
Before you start:
- Who can do it: a realm administrator, in a group that holds
RealmOwner(Delegated administration). Your session can ask the decision API. - Where: today this is done through the API, with your session in
$CVYUH_SESSION(Call the API). - What you need: the rule you want, such as one from Common access policies, and the claims of a token for each kind of caller you want to try.
-
Make a test set for the same resource type, with the same settings as the real one. Read
defaultfirst and copy itscomparator,subjectTypesandconditionTypes:Terminal window curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/policySet?id=default-test" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "comparator": "prefix","conditionTypes": ["OAuth2Scope", "OAuth2AuthorizationDetails", "IPv4", "IPv6", "SimpleTime","AuthenticateToService", "AND", "OR", "NOT"] }'curl https://foobar.cvyuh.com/api/v0/am/objects/v1/policySet/default-test/relationships/resourceTypes \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "targetId": "url" }'No enforcement point reads
default-test, so nothing in it decides a real call. -
Write the rule in the test set, active, and link it to
default-testandurl, as on Policies. Add copies of the real set’s policies that the rule works beside, so the test answers as the real set will. -
Ask what it decides, once for each kind of caller: one it should allow, one it should refuse, and one at the edge. Name the test set in
context.policySet:Terminal window curl https://foobar.cvyuh.com/access/v1/evaluation \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "subject": { "type": "user", "id": "<maya id>","properties": { "claims": { "sub": "<maya id>", "acr": "urn:example:acr:mfa" } } },"resource": { "type": "url", "id": "https://admin.example.com:443/users" },"action": { "name": "DELETE" },"context": { "policySet": "default-test", "ip": "198.51.100.4" } }'{ "decision": false, "context": { "reason": "policy_denied", "decidingPolicy": "office-network-only" } }Leave
groupsout and the realm reads the user’s groups itself. To see who a rule would let in, askPOST https://foobar.cvyuh.com/access/v1/search/subjectwith the same body and"subject": { "type": "user" }(Ask the realm). -
Move it into the real set once every answer is what you meant. Take the link to the test set away, and link the policy to
default:Terminal window curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/policy/office-network-only/relationships/policySet/default-test \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"curl https://foobar.cvyuh.com/api/v0/am/objects/v1/policy/office-network-only/relationships/policySet \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "targetId": "default" }'To change the moment it starts deciding, write it in
defaultwith"active": falseinstead, and set"active": truewhen you’re ready.
Check it worked
Section titled “Check it worked”- In the real set, ask the same questions with
"policySet": "default": the answers match the test set’s. - At the gateway, a refused call answers
403with the same reason. - On the audit trail, each deny, and each decision about an agent, is recorded as
POLICY_DECIDED(Audit → Authentication). Watch it for the first hour for refusals you didn’t expect. To keep every allow too while you watch, setauthorizationSettings.auditDecisionstoall, and back toagentsafter (What is recorded).
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
404 from the decision API | The set or resource type named doesn’t exist | Check context.policySet and resource.type |
Every answer is no_matching_policy | The policy isn’t linked to the test set and the type, or it’s inactive | Link both, and set active: true |
The answer is policies_excluded | A policy in the set breaks the set’s rules | Fix it, or widen the set’s conditionTypes |
| The test set allows, the real set refuses | The real set holds a deny the test set doesn’t | Copy the real set’s denies into the test set and ask again |
The answer is subject_not_active | The user or agent you named isn’t active | Name an active one |
Undo it
Section titled “Undo it”Delete the test set’s policies, then the test set. In the real set, set a policy’s active to false to take it out
of every decision at once.
Related
Section titled “Related”- Common access policies: rules to test.
- Policies: how a decision is reached, and every reason.
- Ask the realm: the decision API in full.