Permissions
Check what a user may do, read their permission tree and set overrides.
Checking authorization is the core thing KPass does for you.
Whether a person signed in through your app's login page or a background service is calling your API on someone's behalf, the question is always the same: is this identity allowed to do this action? KPass answers that one way — the same permission tree, the same allow/deny rules. Don't build a separate authorization system for your API path; call KPass for it.
Permission strings are dot-namespaced (e.g. kpass.apps.members.create) and form a tree. A user's access to a permission is resolved from, in order of precedence: an explicit override on the user, then an override on one of their groups, then plain membership in a role/group that holds the permission — and at any level, an explicit deny always beats an allow.
Check whether a user can do something — this is the one call your app should make before letting a user perform a sensitive action:
curl -X POST https://kpass.one/api/v1/permission/check \
-H "X-Client-Id: YOUR_CLIENT_ID" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"user_id": "YOUR_REFERENCE_ID",
"resource": "myapp.invoices.create"
}'
Response — always 200, check status/access, not the HTTP status code:
{
"status": "success",
"access": "ALLOW",
"user_role": "support-agent",
"user_type": "staff"
}
Read a user's full resolved permission tree:
curl https://kpass.one/api/v1/users/YOUR_REFERENCE_ID/permissions \ -H "X-Client-Id: YOUR_CLIENT_ID" \ -H "X-Api-Secret: YOUR_API_SECRET"
Set a user's permission overrides — full replace, not a diff; omitting a previously-allowed permission revokes it:
curl -X PUT https://kpass.one/api/v1/users/YOUR_REFERENCE_ID/permissions \
-H "X-Client-Id: YOUR_CLIENT_ID" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"permissions": ["myapp.invoices.create", "myapp.invoices.read"]
}'
List the permission catalog for your organisation:
curl https://kpass.one/api/v1/permissions \ -H "X-Client-Id: YOUR_CLIENT_ID" \ -H "X-Api-Secret: YOUR_API_SECRET"