or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
Payloads for the Todo application interop scenario
This document lists the request and response payloads for each of the API requests in the Todo interop scenario.
Version history
type
/id
fields insubject
andresource
into the respectiveproperties
field, to make the payloads compliant with AuthZEN 1.0-01 (Implementer's Draft). Also added documentation for theevaluations
call which leverages AuthZEN 1.1.id
keys to allsubject
andresource
fields to make them compliant with AuthZEN 1.0-00.Overview of the scenario
The Todo application manages a shared todo list between a set of users.
There are 5 actions that the Todo application supports, each with a permission associated with it:
can_read_user
can_read_todos
can_create_todo
can_update_todo
can_delete_todo
There are four roles defined:
viewer
- able to view the shared todo list (can_read_todos
), as well as information about each of the owners of a Todo (notably, their picture) (can_read_user
)editor
-viewer
+ the ability to create new Todos (can_create_todo
), as well as edit and delete Todos that are owned by that useradmin
-editor
+ the ability to delete any Todos (can_delete_todo
)evil_genius
-editor
+ the ability to edit Todos that don't belong to the user (can_update_todo
)There are 5 users defined (based on the "Rick & Morty" cartoon), each with one (or more) roles, defined below in the Subjects section.
Component description
The interop consists of the following components:
The URIs listed in the document below are the contracts between the React app and the Node.JS backend.
The Node.JS backend will take two environment variables - AUTHZEN_PDP_URL and AUTHZEN_PDP_API_KEY - and use the AUTHZEN_PDP_URL to formulate the REST API call to the PDP, using the AUTHZEN_PDP_API_KEY as the Authorization header.
The payloads listed below are the contract between the Node.JS backend and the PDP.
The node.js backend is the PEP.
Subjects
Note: in every request payload, the subject indicated by
<subject_from_jwt>
is one of the following strings:This will be extracted from the
sub
claim in the JWT passed in as a bearer token in the Authorization header of each request, and passed into the AuthZEN request.Attributes associated with users (expected to come from PIP)
These are noted below in JSON format, with the key being the PID string from the table above, and the value being a set of attributes associated with the user.
The PIP can, of course, express this in any way they desire. The policy for each implementation has its own contract with its PIP, and this contract is outside of the scope of the PEP-PDP interop scenario.
Requests and payloads
Unless otherwise noted, these are payloads for the
evaluation
API, and are meant to be sent using the following HTTP(S) request:GET /users/{userID}
Get information (e.g. email, picture) associated with a user. This is used by the backend to render the picture of the user that owns each todo.
For simplicity, the policy always returns
true
.Request payload
Response payload
For every subject and resource combination:
GET /todos
Get the list of todos.
Evaluation API payload
For simplicity, the policy always returns
true
for every user.Evaluation API Request payload
Evaluation API Response payload
For every subject and resource combination:
AuthZEN 1.1-preview semantics
AuthZEN 1.1 provides an
evaluations
API which enables a PEP to "boxcar" a number of authorization requests in a single round-trip.The Todo Application uses this facility to determine which Todos a user is able to complete, and sends this information to the React front-end to help in rendering Todos that are not completable by the users as "disabled".
Evaluations API Request payload
Evaluations API Response payload
The
evaluations
array contains the result of each evaluation request sent in the request payload. For example, for the user Morty, using the following request payload:The response payload will be:
This is because Morty cannot update Rick's todo, but can update his own todo.
POST /todos
Create a new todo.
The policy evaluates the subject's
roles
attribute to determine whether the user can create a new todo.Request payload
Response payload
Only users with a
roles
attribute that containsadmin
oreditor
return atrue
decision. In the user set above, this includes Rick, Morty, and Summer.For the other two users, Beth and Jerry, the decision is
false
.PUT /todos/{id}
Edit (complete) a todo.
The policy allows the operation if the subject's
roles
attribute contains theevil_genius
role, OR if the subject'sroles
contains theeditor
role AND the subject is the owner of the todo.The
resource
contains an attribute calledownerID
which contains theid
of the owner (which is defined in the "Attributes" section above, and is the email address of the owner).Request payload
Response payload
Only users with a
roles
attribute that containsevil_genius
(Rick), OR the owner of the todo, return atrue
decision.For the user Morty, the following request will return a
true
decision:For a different value of
ownerID
, the decision will befalse
:DELETE /todos/{id}
Delete a todo.
The policy allows the operation if the subject's
roles
attribute contains theadmin
role, OR if the subject'sroles
contains theeditor
role AND the subject is the owner of the todo.The
resource
contains an attribute calledownerID
which contains theid
of the owner (which is defined in the "Attributes" section above, and is the email address of the owner).Request payload
Response payload
Only users with a
roles
attribute that containsadmin
(Rick), OR the owner of the todo, return atrue
decision.For the user Morty, the following request will return a
true
decision:For a different value of
ownerID
, the decision will befalse
: