Authorize with Authwise Access
Authwise Access is the authorization engine in the identity server. You describe what your API allows as permissions and roles, grant roles to people, groups, and applications, and your API enforces the result. This page explains the model and helps you choose how to enforce it. The pages that follow are the tasks.
Access answers one question:
Is this subject allowed to use this permission on this resource?
For example: is the person u-g54uczbi7tzv allowed to use
invoices.approve on invoice/inv-9? The answer is allowed or denied, with the reason.
The model
Section titled “The model”Everything you define belongs to an audience, the object that stands for your API. Each audience has its own catalog, and there is nothing to turn on.
| Object | What it is | Example |
|---|---|---|
| Permission | One action your API allows. You choose the name. | invoices.read |
| Role | A named set of permissions. | invoices.editor |
| Binding | A grant: a subject holds a role on a resource. | u-g54uczbi7tzv holds invoices.editor on the whole API |
| Subject | Who the grant is for: a user, a group, or a client, which is an application. | user/u-g54uczbi7tzv |
| Resource | What the grant covers: the whole API, or one object in it. | account/acc-3 |
| Condition | An optional expression that must be true for a binding to count. | request.network == "office" |
A binding can also carry an expiry time, after which it stops counting.
Roles only add. A binding grants; nothing denies. A subject can do something when at least one binding that applies grants it.
How a decision is made
Section titled “How a decision is made”For a question about a subject, a permission, and a resource, the engine:
- Takes the subject and every group the subject belongs to. A role granted to a group counts for its members.
- Takes the resource and each resource above it, up to the whole API. A role granted on an account counts for the invoices in that account.
- Looks for a binding of any of those subjects on any of those resources that has not expired, whose role contains the permission, and whose condition, if it has one, is true.
If the engine finds such a binding, the answer is allowed. Otherwise it is denied.
Choose how your API enforces it
Section titled “Choose how your API enforces it”Your API can read the decision from the access token, ask the identity server at request time, or do both.
| Token claims | Runtime check | |
|---|---|---|
| How | The access token carries roles and permissions. Your API validates the token and matches names. | Your API sends the caller’s access token to POST /v1/access:check and reads the decision. |
| Network call per decision | None | One |
| A revoked grant takes effect | When the token expires | On the next check |
| Grants on one resource, such as one account | Not carried | Decided |
| Conditions | Not carried. A conditional grant is left out. | Evaluated |
| Size | At most 100 roles and 500 permissions in a token | No limit on the catalog |
Start with token claims when your API only needs to know what a caller can do across the whole API, and a delay of one token lifetime on a revoked grant is acceptable. Use the runtime check when grants differ per resource, when they carry conditions, or when a revoked grant must stop working at once. The two read the same catalog, so you can use claims for coarse decisions and the check for the fine ones.
Names you can’t use
Section titled “Names you can’t use”The identity server keeps its own permissions and roles in the same model. Their namespaces are reserved, and a write that uses one is refused:
- A permission whose name or service starts with
access,audit,identity,tenancy, ortenancyadmin. - A role whose name starts with
access,identity,tenancy, ortenant.
Name your permissions and roles after your own API, such as invoices.read
and invoices.editor.
What’s next
Section titled “What’s next”- Define roles and grant them.
- Read roles and permissions from the token, or check a permission from your API.
- Grant access to one resource when a grant must cover one account, project, or document instead of the whole API.