2016-11-29 15:30:53 +00:00
[[_service_protection_permission_api_papi]]
2022-04-18 14:10:57 +00:00
= Managing permission requests
2016-06-05 22:17:31 +00:00
2016-11-15 21:34:20 +00:00
Resource servers using the UMA protocol can use a specific endpoint to manage permission requests. This endpoint provides a UMA-compliant flow for registering permission requests and obtaining a permission ticket.
2016-06-05 22:17:31 +00:00
2022-02-08 13:07:16 +00:00
[source,subs="attributes+"]
----
http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission
----
2016-06-05 22:17:31 +00:00
2017-08-28 12:50:14 +00:00
A <<_overview_terminology_permission_ticket, permission ticket>> is a special security token type representing a permission request. Per the UMA specification, a permission ticket is:
2016-06-05 22:17:31 +00:00
`A correlation handle that is conveyed from an authorization server to a resource server, from a resource server to a client, and ultimately from a client back to an authorization server, to enable the authorization server to assess the correct policies to apply to a request for authorization data.`
2024-08-19 07:48:48 +00:00
In most cases, you won't need to deal with this endpoint directly. {project_name} provides a policy enforcer that enables UMA for your
2017-06-02 19:10:00 +00:00
resource server so it can obtain a permission ticket from the authorization server, return this ticket to client application, and enforce authorization decisions based on a final requesting party token (RPT).
2017-08-28 12:50:14 +00:00
The process of obtaining permission tickets from {project_name} is performed by resource servers and not regular client applications,
2017-06-02 19:10:00 +00:00
where permission tickets are obtained when a client tries to access a protected resource without the necessary grants to access the resource. The issuance of
permission tickets is an important aspects when using UMA as it allows resource servers to:
* Abstract from clients the data associated with the resources protected by the resource server
2017-08-28 12:50:14 +00:00
* Register in the {project_name} authorization requests which in turn can be used later in workflows to grant access based on the resource's owner consent
2017-06-02 19:10:00 +00:00
* Decouple resource servers from authorization servers and allow them to protect and manage their resources using different authorization servers
Client wise, a permission ticket has also important aspects that its worthy to highlight:
* Clients don't need to know about how authorization data is associated with protected resources. A permission ticket is completely opaque to clients.
* Clients can have access to resources on different resource servers and protected by different authorization servers
These are just some of the benefits brought by UMA where other aspects of UMA are strongly based on permission tickets, specially regarding
2017-10-09 06:38:46 +00:00
privacy and user controlled access to their resources.
2018-06-22 19:50:10 +00:00
2022-04-18 14:10:57 +00:00
== Creating permission ticket
2018-06-22 19:50:10 +00:00
To create a permission ticket, send an HTTP POST request as follows:
2022-02-08 13:07:16 +00:00
[source,bash,subs="attributes+"]
----
2018-06-22 19:50:10 +00:00
curl -X POST \
2022-02-08 13:07:16 +00:00
http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission \
2018-06-22 19:50:10 +00:00
-H 'Authorization: Bearer '$pat \
-H 'Content-Type: application/json' \
-d '[
{
"resource_id": "{resource_id}",
"resource_scopes": [
"view"
]
}
]'
2022-02-08 13:07:16 +00:00
----
2018-06-22 19:50:10 +00:00
When creating tickets you can also push arbitrary claims and associate these claims with the ticket:
2022-02-08 13:07:16 +00:00
[source,bash,subs="attributes+"]
----
2018-06-22 19:50:10 +00:00
curl -X POST \
2022-02-08 13:07:16 +00:00
http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission \
2018-06-22 19:50:10 +00:00
-H 'Authorization: Bearer '$pat \
-H 'Content-Type: application/json' \
-d '[
{
"resource_id": "{resource_id}",
"resource_scopes": [
"view"
],
"claims": {
"organization": ["acme"]
}
}
]'
2022-02-08 13:07:16 +00:00
----
2018-06-22 19:50:10 +00:00
Where these claims will be available to your policies when evaluating permissions for the resource and scope(s) associated
with the permission ticket.
2019-04-10 14:02:53 +00:00
== Other non UMA-compliant endpoints
=== Creating permission ticket
To grant permissions for a specific resource with id {resource_id} to a user with id {user_id}, as an owner of the resource send an HTTP POST request as follows:
2022-02-08 13:07:16 +00:00
[source,bash,subs="attributes+"]
----
2019-04-10 14:02:53 +00:00
curl -X POST \
2022-02-08 13:07:16 +00:00
http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission/ticket \
2019-04-10 14:02:53 +00:00
-H 'Authorization: Bearer '$access_token \
-H 'Content-Type: application/json' \
-d '{
"resource": "{resource_id}",
"requester": "{user_id}",
"granted": true,
"scopeName": "view"
}'
2022-02-08 13:07:16 +00:00
----
2019-04-10 14:02:53 +00:00
=== Getting permission tickets
2022-02-08 13:07:16 +00:00
[source,bash,subs="attributes+"]
----
curl http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission/ticket \
2019-04-10 14:02:53 +00:00
-H 'Authorization: Bearer '$access_token
2022-02-08 13:07:16 +00:00
----
2019-04-10 14:02:53 +00:00
You can use any of these query parameters:
* `scopeId`
* `resourceId`
* `owner`
* `requester`
* `granted`
* `returnNames`
* `first`
* `max`
=== Updating permission ticket
2022-02-08 13:07:16 +00:00
[source,bash,subs="attributes+"]
----
2019-04-10 14:02:53 +00:00
curl -X PUT \
2022-02-08 13:07:16 +00:00
http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission/ticket \
2019-04-10 14:02:53 +00:00
-H 'Authorization: Bearer '$access_token \
-H 'Content-Type: application/json' \
-d '{
"id": "{ticket_id}"
"resource": "{resource_id}",
"requester": "{user_id}",
"granted": false,
"scopeName": "view"
}'
2022-02-08 13:07:16 +00:00
----
2019-04-10 14:02:53 +00:00
=== Deleting permission ticket
2022-02-08 13:07:16 +00:00
[source,bash,subs="attributes+"]
----
curl -X DELETE http://${host}:${port}{kc_realms_path}/${realm_name}/authz/protection/permission/ticket/{ticket_id} \
2019-04-10 14:02:53 +00:00
-H 'Authorization: Bearer '$access_token
2024-08-19 07:48:48 +00:00
----