forked from trustbloc/sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi-spec.yml
417 lines (408 loc) · 12.5 KB
/
openapi-spec.yml
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# Copyright SecureKey Technologies Inc.
#
# SPDX-License-Identifier: Apache-2.0
swagger: "2.0"
info:
title: Comparator
description: |
The Comparator orchestrates user requests for comparisons and authorizations to allow comparisons.
To authorize a comparison on a Vault Server document, the Comparator requests the Vault Server authorization
for the remote _Confidential Storage Hub_ to read the documents on the user's behalf. A resource is then created
at the remote Confidential Storage Hub configured with the Vault Server authorization tokens. This resource - hosted
on the Confidential Storage Hub itself - is in turn protected by a newly minted token authorizing the requesting
party to _reference_ the resource in a comparison. **Note that 'reference' is not the same as 'read'.** The
new authorization token issued by the Confidential Storage Hub does **not** allow the requesting party to extract
documents - it just allows them to 'reference' them in a comparison request.
To execute a comparison, the Comparator forwards the request with the authorization tokens to the remote
Confidential Storage Hub.
version: 1.0.0
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
paths:
/authorizations:
post:
description: |
Authorize a third party to perform a comparison on a Vault Server document.
Authorization to read the document is obtained at the Vault Server and pre-configured in the remote
Confidential Storage Hub, to be referenced during the actual comparison operation.
consumes:
- application/json
produces:
- application/json
parameters:
- name: authorization
in: body
required: true
schema:
$ref: "#/definitions/Authorization"
responses:
200:
description: Authorization created.
headers:
Location:
description: Location of the Authorization.
type: string
schema:
$ref: "#/definitions/Authorization"
examples: {
"application/json": {
"id": "123456",
"requestingParty": "did:example:party_doing_comparison",
"scope": [
{
"vaultID": "did:example:123",
"docID": "batphone",
"actions": [ "compare" ],
"caveats": [
{
"type": "expiry",
"duration": 600
}
],
"authToken": "21tDAKCERh95uGgKbJNHYp"
}
]
}
}
500:
description: Generic Error
schema:
$ref: "#/definitions/Error"
/compare:
post:
description: |
Execute a _remote_ comparison of the Confidential Storage documents fetched with the credentials provided.
This comparison is performed remotely by the Confidential Storage hub using the credentials.
The comparison's operator's type determines the type of comparison to be performed.
The result is always a boolean value.
consumes:
- application/json
produces:
- application/json
parameters:
- name: comparison
in: body
required: true
schema:
$ref: "#/definitions/Comparison"
responses:
200:
description: Result of comparison.
schema:
$ref: "#/definitions/ComparisonResult"
examples: {
"application/json": {
"result": true
}
}
500:
description: Generic Error
schema:
$ref: "#/definitions/Error"
/extract:
post:
description: |
Extract the contents of one or more documents using the authorization tokens provided. The tokens originate
from authorizations granted at other Comparators. Each element in the response is correlated to its query
via the ID.
consumes:
- application/json
produces:
- application/json
parameters:
- name: extract
in: body
required: true
schema:
$ref: "#/definitions/Extract"
responses:
200:
description: list of extracted documents
schema:
$ref: "#/definitions/ExtractResp"
500:
description: Generic Error
schema:
$ref: "#/definitions/Error"
/config:
get:
description: |
Returns the Comparator's auto-generated configuration.
This configuration may be used for instance to configure a profile in the VC HTTP API for issuance of
Verifiable Credentials using the same DID and keys.
produces:
- application/json
responses:
200:
description: The comparator's configuration.
schema:
$ref: "#/definitions/Config"
examples: {
"application/json": {
"did": "did:example:H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV",
"authKeyURL": "did:example:H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV#H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV",
"key": {
"keys": [
{
"kty": "EC",
"crv": "P-256",
"x": "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y": "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"d": "870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE",
"kid": "1"
}
]
}
}
}
500:
description: Generic Error
schema:
$ref: "#/definitions/Error"
definitions:
Authorization:
description: |
An authorization object encodes the permissions granted to a third party. Its `scope` details the allowed
action and the object on which the action will be performed. The `requestingParty` is the third party
allowed to perform those actions.
The `authToken` is an opaque tokens granting the `requestingParty` the priviledge of running a comparison
with the document identified in `scope` at the remote Confidential Storage Hub.
type: object
example: {
"requestingParty": "did:example:party_doing_comparison",
"scope": [
{
"vaultID": "did:example:123",
"docID": "batphone",
"actions": [ "compare" ],
"caveats": [
{
"type": "expiry",
"duration": 600
}
],
}
]
}
required:
- scope
- requestingParty
properties:
id:
type: string
description: The authorization's unique ID.
scope:
$ref: "#/definitions/Scope"
requestingParty:
description: KeyID in the format of a DID URL that identifies the party granted authorization.
type: string
authToken:
type: string
description: |
An opaque authorization token authorizing the requesting party to perform a comparison
referencing the document in the `scope`.
Scope:
type: object
required:
- docID
- actions
- authTokens
properties:
vaultID:
description: the Vault Server ID (DID)
type: string
docID:
description: an identifier for a document stored in the Vault Server.
type: string
docAttrPath:
description: Optional json path. Authorizes the comparison of a portion of the document.
type: string
authTokens:
type: object
properties:
edv:
type: string
kms:
type: string
actions:
type: array
items:
type: string
enum:
- compare
caveats:
type: array
items:
$ref: "#/definitions/Caveat"
Caveat:
description: |
Caveats place constraints on the scope of an authorization.
For example, an authorization may allow to compare a document but only for a certain length of time (caveat).
type: object
required:
- type
discriminator: type
properties:
type:
type: string
ExpiryCaveat:
allOf:
- $ref: "#/definitions/Caveat"
- type: object
properties:
duration:
type: integer
description: Duration (in seconds) for which this authorization will remain valid.
Comparison:
description: |
A comparison is a request to compare two or more documents.
Comparisons have an operator that determines the kind of comparison to be performed.
type: object
example: {
"op": {
"type": "EqOp",
"args": [
{
"type": "DocQuery",
"vaultID": "did:example:123",
"docID": "batphone",
"authTokens": {
"edv": "21tDAKCERh95uGgKbJNHYp",
"kms": "bcehfew7h32f32h7af3"
}
},
{
"type": "AuthorizedQuery",
"authToken": "123456789abcdefghi"
}
]
}
}
properties:
op:
$ref: "#/definitions/Operator"
ComparisonResult:
type: object
properties:
result:
type: boolean
Operator:
description: |
Operators indicate the kind of comparison operation to be performed.
type: object
required:
- type
properties:
type:
type: string
discriminator: type
EqOp:
allOf:
- $ref: "#/definitions/Operator"
- type: object
required:
- args
properties:
args:
type: array
items:
$ref: "#/definitions/Query"
minItems: 2
Query:
description: A query identifies a document to be compared.
type: object
required:
- type
properties:
id:
type: string
type:
type: string
discriminator: type
DocQuery:
description: |
DocQuery identifies a document by directly referencing the document's Vault Server vaultID and docID.
It also contains the necessary authorization tokens to access the document at the remote Confidential Storage
vault and decrypt with the WebKMS key.
allOf:
- $ref: "#/definitions/Query"
- type: object
required:
- vaultID
- docID
- authTokens
properties:
vaultID:
type: string
docID:
description: an identifier for a document stored in the Vault Server.
type: string
docAttrPath:
description: |
By default, a DocQuery identifies a document in its entirety, which means the entire contents of the
document are used in the comparison. `docAttrPath` is a JSONPath that allows a _portion_ of the
document to be used during the comparison.
type: string
authTokens:
type: object
properties:
edv:
type: string
kms:
type: string
AuthorizedQuery:
description: |
AuthorizedQuery is a query that has been pre-authorized by another Comparator.
The AuthorizedQuery's `authToken` is the authorization token handed back by the other Comparator authorizing
the comparison on a document.
allOf:
- $ref: "#/definitions/Query"
- type: object
required:
- authToken
properties:
authToken:
type: string
Config:
type: object
required:
- did
- key
properties:
did:
type: string
description: The comparator's unique DID.
authKeyURL:
type: string
description: The comparator's authentication key's keyID in the format of a DID URL.
key:
type: object
description: A JWK Set containing the primary public/private key pair.
Extract:
type: object
required:
- queries
properties:
queries:
type: array
items:
$ref: "#/definitions/Query"
ExtractResp:
type: object
required:
- documents
properties:
documents:
type: array
items:
properties:
id:
type: string
contents:
type: object
Error:
type: object
properties:
errMessage:
type: string