-
Notifications
You must be signed in to change notification settings - Fork 5
/
apiary.apib
309 lines (221 loc) · 9.74 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
FORMAT: 1A
# Keypass
Keypass is multi-tenant XACML server with PAP (Policy Administration Point) and
PDP (Policy Detention Point) capabilities.
Tenancy is defined by means of an HTTP header. Default configuration uses
`Fiware-Service` as the tenant header name, but it can be easily changed
modifying it in the config file.
The PDP endpoint will evaluate the Policies for the subjects contained in a
XACML request. This is a design decision took by Keypass in order to simplify
how the application is used.
You, as a developer, may wonder what a subject is, and why policies are grouped
around them. To simplify, a subject is the same you put in a `subject-id` in
an XACML request. You can then structure your user, groups and roles as usual
in your preferred Identity Management system, just taking into account that
those `ids` (subject, roles, groups) shall be used in your PEP when building
the XACML request.
Applying the policies per subject means that policies must be managed grouping
them by subject. Keypass PAP API is designed to accomplish this.
As XACML is an XML specification, Keypass API offers an XML Restful API.
From the PAP REST point of view, the only resource is the Policy, with resides
in a Subject of a Tenant. Both Tenant and Subject may be seen as namespaces, as
they are not resources _per se_ .
# Group PAP
Policy Administration Point
## Policies [/pap/v1/subject/:id]
+ Model (application/xml)
+ Headers
```
Fiware-Service: myTenant
```
+ Body
```xml
<PolicySet xmlns:ns0="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
xmlns:ns1="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
ns0:PolicySetId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"
ns1:Version="1.0">
<Policy xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17
http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd"
PolicyId="policy03"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit"
Version="1.0" xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
<AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string"
>fiware:orion:.*</AttributeValue>
<AttributeDesignator
AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
DataType="http://www.w3.org/2001/XMLSchema#string"
MustBePresent="true"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" />
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule RuleId="policy03rule01" Effect="Permit">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
<AttributeDesignator
AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
DataType="http://www.w3.org/2001/XMLSchema#string"
MustBePresent="true"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" />
</Apply>
<AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string"
>read</AttributeValue>
</Apply>
</Condition>
</Rule>
</Policy>
</PolicySet>
```
+ Parameters
+ id (string) ... Subject identifier, used to group policies
### Create a Policy [POST]
+ Request
[Policy][]
+ Response 201
+ Headers
Location: http://KEYPASS_HOST/pap/v1/subject/:id/policy/:policyId
### Get Subject Policies [GET]
+ Request
+ Headers
```
Fiware-Service: myTenant
```
+ Response 200
[Policies][]
### Delete all Subject Policies [DELETE]
+ Request
+ Headers
```
Fiware-Service: myTenant
```
+ Response 204
## Tenant [/pap/v1]
### Delete all Tenant Policies [DELETE]
+ Request
+ Headers
```
Fiware-Service: myTenant
```
+ Response 204
## Policy [/pap/v1/subject/:id/policy/:policyId]
+ Parameters
+ id (string) ... Subject identifier, used to group policies
+ policyId (string) ... Policy Identifier
+ Model (application/xml)
+ Headers
```
Fiware-Service: myTenant
```
+ Body
```xml
<Policy xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17
http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd"
PolicyId="policy03"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit"
Version="1.0" xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
<AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string"
>fiware:orion:.*</AttributeValue>
<AttributeDesignator
AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
DataType="http://www.w3.org/2001/XMLSchema#string"
MustBePresent="true"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" />
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule RuleId="policy03rule01" Effect="Permit">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
<AttributeDesignator
AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
DataType="http://www.w3.org/2001/XMLSchema#string"
MustBePresent="true"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" />
</Apply>
<AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string"
>read</AttributeValue>
</Apply>
</Condition>
</Rule>
</Policy>
```
### Get a Policy [GET]
+ Request
[Policy][]
+ Response 200
[Policy][]
+ Response 404
### Update a Policy [PUT]
+ Request
[Policy][]
+ Response 200
[Policy][]
+ Response 404
### Delete a Policy [DELETE]
+ Request
+ Headers
```
Fiware-Service: myTenant
```
+ Response 200
[Policy][]
+ Response 404
# Group PDP
Policy Decision Point
## Validation [/pdp/v3]
### Validate requests [POST]
+ Request
+ Headers
```
Fiware-Service: myTenant
```
+ Body
```xml
<Request xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd" ReturnPolicyIdList="false" CombinedDecision="false" xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
<Attribute IncludeInResult="false" AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">role12345</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
<Attribute IncludeInResult="false" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">fiware:orion:tenant1234:us-west-1:res9876</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
<Attribute IncludeInResult="false" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
</Attribute>
</Attributes>
</Request>
```
+ Response 200
```xml
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<Result>
<Decision>NotApplicable</Decision>
<Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</Status>
</Result>
</Response>
```