Write a policy in plain language
Describe who may do what in a sentence, review the roles or relationships that LumoAuth proposes, and apply them.
What it shows
- You describe the rule in a sentence on the portal page AI policy authoring.
- A language model turns the sentence into a draft: roles, permissions and which role holds which permission. For a rule about relationships, it also drafts relationship namespaces.
- You read the draft. Nothing changes until you click Apply policy.
- Applying creates the roles and permissions. The script shows them with the lumo CLI, and tests them with a permission check.
The draft is a proposal for you to review. The model never changes your organization by itself.
Before you start
- The permissions
policies.viewto open the page, andpolicies.create,roles.createandroles.assign-permissionsto apply a draft. - The lumo CLI and
jq.
Write and apply the policy in the portal
- Open Access control, Roles & permissions, and click Draft with AI. The page AI policy authoring opens.
- Under Policy description, enter the rule: "Two roles, no relationships: support leads can view tickets and issue refunds; support agents can view tickets and reply to them."
- Click Analyze and preview. The Preview shows the tables Roles, Permissions and Assignments.
- To change the draft, click Reset, change the sentence and analyze it again. The tables cannot be edited.
- Click Apply policy, and confirm with Apply policy in the dialog.
- Give the new role Support Lead to a test user, under Identity, Users.
These steps were followed on a LumoAuth organization. The names in the draft come from a language model and can differ from run to run, also for the same sentence. The output shows the names of one run.
Code
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization. The names in the draft come from a language model and can differ from run to run, also for the same sentence. The output shows the names of one run.
- lumo CLI
authorization/policies-from-plain-language/cli/review.sh
#!/bin/sh
# Show the roles that an applied draft created, and test them with a
# permission check, with the lumo CLI and jq.
#
# sh authorization/policies-from-plain-language/cli/review.sh
set -eu
# The slugs come from the draft. Set ROLES when your draft named other roles.
ROLES="${ROLES:-support_lead support_agent}"
# The CLI reads its own three variables. With them it needs no `lumo login`.
export LUMO_BASE_URL="$LUMOAUTH_URL" LUMO_ORG="$LUMOAUTH_ORG_ID" LUMO_API_KEY="$LUMOAUTH_API_KEY"
for role in $ROLES; do
lumo roles get "$role" -o json | jq -r '.data | "\(.slug): \([.permissions[].slug] | join(", "))"'
done
# A person who holds the first role. The check endpoint is not under
# /orgs/{org}: `lumo api` takes the path as it is.
for permission in refunds.issue tickets.reply; do
lumo api POST /api/v1/authz/check \
--data "{\"permission\": \"$permission\", \"subject\": {\"type\": \"user\", \"id\": \"$LEAD_USER_ID\"}}" \
| jq -r --arg p "$permission" '"lead: \($p) -> \(if .allowed then "allowed" else "denied" end)"'
done
sh authorization/policies-from-plain-language/cli/review.sh
Check the result
Output
support_lead: tickets.view, refunds.issue
support_agent: tickets.view, tickets.reply
lead: refunds.issue -> allowed
lead: tickets.reply -> denied
- The page Roles & permissions lists the two new roles with their permissions.
- Before you click Apply policy,
lumo roles get support_leadanswers that the role does not exist.
Limits
- The model drafts roles, permissions and relationships. It does not draft attribute rules: write those under Attribute rules.
- Seed tuples in a draft are examples with placeholder IDs. Applying never creates them.
- Applying relationship namespaces needs fine-grained authorization: check that your plan includes it in the plans matrix. A draft with roles only applies on every plan.
- Applying refuses the whole draft when a role is a system role or a permission is reserved for the platform. The page then names the entry.
- A removal in the draft takes one permission away from one role. It is not a deny rule.
- The sentence goes to a language model. When AI features are not available to your organization, the page shows AI features disabled instead of the form.