-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
507 lines (468 loc) · 15.6 KB
/
swagger.yaml
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
swagger: "2.0" # https://stackoverflow.com/a/59749691/14797322
info:
title: "magiclinks.dev"
description: "The API specification for the magiclinksdev project.
\n\n
The default JWK Set relative URL path is `/api/v1/jwks.json`.
\n\n
The documentation site is at https://docs.magiclinks.dev
\n
This is an ELv2 licensed project: https://github.com/MicahParks/magiclinksdev
\n
The optional SaaS platform's landing page is: https://magiclinks.dev
"
version: "1.0.0"
host: "magiclinks.dev"
basePath: "/api/v1"
schemes:
- "https"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/ready:
get:
summary: "Check if the service is running and ready to accept requests."
description: "Check if the service is running and ready to accept requests."
operationId: "ready"
responses:
200:
description: "The service is running and ready to accept requests."
default:
description: "The service is not ready to accept requests."
/admin/service-account/create:
post:
tags:
- "admin"
summary: "Create a new service account"
description: "Create a new service account with the parameters."
operationId: "serviceAccountCreate"
parameters:
- in: "body"
name: "body"
description: "Service account object that needs to be added."
required: true
schema:
$ref: "#/definitions/ServiceAccountCreateRequest"
responses:
201:
description: "successful operation"
schema:
$ref: "#/definitions/ServiceAccountCreateResponse"
default:
description: "An error occurred."
schema:
$ref: "#/definitions/Error"
/jwt/create:
post:
summary: "Create a JWT, typically for a JWT refresh."
description: "Create a JWT with the parameters. The intended use case is to refresh an authentic and valid JWT."
operationId: "jwtCreate"
parameters:
- name: "body"
in: "body"
description: "The JWT payload."
required: true
schema:
$ref: "#/definitions/JWTCreateRequest"
responses:
201:
description: "The JWT was created successfully."
schema:
$ref: "#/definitions/JWTCreateResponse"
default:
description: "An error occurred."
schema:
$ref: "#/definitions/Error"
/jwt/validate:
post:
summary: "Validate a JWT."
description: "Validate a JWT and return the payload. Ideally the client would cache a copy of the JWK Set and
validate JWTs locally. This endpoint is for use cases where the native language does not have an adequate JWK Set
client. Consider deploying an instance of the JWK Set Client Proxy (JCP) if you need this in production:
https://github.com/MicahParks/jcp"
operationId: "jwtValidate"
parameters:
- in: "body"
name: "body"
description: "The JWT to validate."
required: true
schema:
$ref: "#/definitions/JWTValidateRequest"
responses:
200:
description: "The JWT was signed by an active key in the JWK Set."
schema:
$ref: "#/definitions/JWTValidateResponse"
422:
description: "The given JWT was invalid."
schema:
$ref: "#/definitions/Error"
default:
description: "An error occurred."
schema:
$ref: "#/definitions/Error"
/link/create:
post:
summary: "Create a magic link."
description: "Create a magic link that, when clicked, will create a JWT with the given claims and include that JWT
in the URL query key of a redirect."
operationId: "linkCreate"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/LinkCreateRequest"
responses:
201:
description: "The magic link was created successfully."
schema:
$ref: "#/definitions/LinkCreateResponse"
default:
description: "An unexpected error occurred."
schema:
$ref: "#/definitions/Error"
/email-link/create:
post:
summary: "Send a magic link via email."
description: "Create and send a magic link via email."
operationId: "emailLinkCreate"
parameters:
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/EmailLinkCreateRequest"
responses:
201:
description: "The request has been accepted by the email provider."
schema:
$ref: "#/definitions/EmailLinkCreateResponse"
default:
description: "An unexpected error occurred."
schema:
$ref: "#/definitions/Error"
definitions:
Error:
type: "object"
properties:
code:
type: "integer"
description: "A copy of the HTTP response status code."
format: "int32"
message:
type: "string"
description: "A human-readable error message."
requestMetadata:
$ref: "#/definitions/RequestMetadata"
RequestMetadata:
type: "object"
properties:
uuid:
type: "string"
description: "A UUID that uniquely identifies the request."
format: "uuid"
APIKey:
type: "object"
properties:
apiKey:
type: "string"
description: "The API key."
Audience:
type: "object"
properties:
apiKeys:
type: "array"
description: "API keys for this audience."
items:
$ref: "#/definitions/APIKey"
aud:
type: "string"
description: "The audience of JWTs created for this service account context."
serviceLogo:
type: "string"
description: "The URL of the service account's service logo."
serviceName:
type: "string"
description: "The name of the service account's service."
serviceURL:
type: "string"
description: "The URL of the landing page for the service account's service."
ServiceAccountMeta:
type: "object"
properties:
admin:
type: "boolean"
description: "Whether the service account is an admin."
uuid:
type: "string"
description: "The UUID of the service account."
format: "uuid"
ServiceAccount:
type: "object"
properties:
audiences:
type: "array"
description: "The audiences for this service account."
items:
$ref: "#/definitions/Audience"
meta:
$ref: "#/definitions/ServiceAccountMeta"
JWTClaims:
description: "Any valid JSON object."
type: "object"
properties:
claims:
description: 'Any valid JSON object. Do not provide any JSON attributes mentioned in RFC 7519 section 4.1 as
this will cause an error. These are JWT "Registered Claim Names".'
type: "object"
externalDocs:
description: "RFC 7519 section 4.1"
url: "https://tools.ietf.org/html/rfc7519#section-4.1"
JWTCreateRequest:
description: "The request body for the /jwt/create endpoint."
type: "object"
properties:
jwtCreateArgs:
$ref: "#/definitions/JWTCreateArgs"
required:
- "jwtCreateArgs"
JWTCreateArgs:
description: "Parameters used to create a JWT."
type: "object"
properties:
jwtClaims:
description: "The JWT claims used to create the signed JWT."
$ref: "#/definitions/JWTClaims"
jwtLifespanSeconds:
description: "The lifespan of the JWT in seconds. The JWT's lifespan starts after the magic link has been
visited and the JWT is signed. It defaults to 5 minutes. The minimum value is 5 and the maximum value is
2,592,000."
default: 300
type: "integer"
JWTCreateResults:
description: "The results for creating a JWT."
type: "object"
properties:
jwt:
description: "The signed JWT."
type: "string"
JWTCreateResponse:
description: "The response body for the /jwt/create endpoint."
type: "object"
properties:
jwtCreateResults:
$ref: "#/definitions/JWTCreateResults"
requestMetadata:
$ref: "#/definitions/RequestMetadata"
JWTValidateRequest:
description: "The request body for the /jwt/validate endpoint."
type: "object"
properties:
jwtValidateArgs:
$ref: "#/definitions/JWTValidateArgs"
required:
- "jwtValidateArgs"
JWTValidateArgs:
description: "Parameters used to validate a JWT."
type: "object"
properties:
jwt:
description: "The JWT to validate."
type: "string"
JWTValidateResults:
description: "The results for validateing a JWT."
type: "object"
properties:
claims:
description: 'Any valid JSON object. Do not provide any JSON attributes mentioned in RFC 7519 section 4.1 as
this will cause an error. These are JWT "Registered Claim Names".'
type: "object"
externalDocs:
description: "RFC 7519 section 4.1"
url: "https://tools.ietf.org/html/rfc7519#section-4.1"
JWTValidateResponse:
description: "The response body for the /jwt/validate endpoint."
type: "object"
properties:
jwtValidateResults:
$ref: "#/definitions/JWTValidateResults"
requestMetadata:
$ref: "#/definitions/RequestMetadata"
LinkCreateArgs:
description: "Parameters to create any magic link."
type: "object"
properties:
jwtCreateArgs:
description: "The parameters used to create the JWT to pass upon redirection."
$ref: "#/definitions/JWTCreateArgs"
linkExpires:
description: "The number of seconds the link should be active for after the request has been processed. It
defaults to 1 hour. The minimum value is 5 and the maximum value is 2,592,000."
type: "integer"
default: 3600
redirectQueryKey:
description: 'The URL query key in the redirectURL to contain the signed JWT when the magic link is used. By
default, "jwt" is used.'
type: "string"
redirectURL:
description: "The URL to redirect to with the signed JWT when the link is used."
type: "string"
required:
- "redirectURL"
LinkCreateRequest:
description: "The request body for the /link/create endpoint."
type: "object"
properties:
linkArgs:
$ref: "#/definitions/LinkCreateArgs"
required:
- "linkArgs"
LinkCreateResults:
description: "The results for creating a magic link."
type: "object"
properties:
magicLink:
description: "The magic link that, when visited, will sign a JWT with the given information and pass it along in
a redirect to the given URL. The link can only be used once. This link should as if it were the signed JWT."
type: "string"
secret:
description: "The secret embedded in the magic link. It can only be used once, so using it will automatically
expire the link."
type: "string"
LinkCreateResponse:
description: "The response body for the /link/create endpoint."
type: "object"
properties:
linkCreateResults:
$ref: "#/definitions/LinkCreateResults"
requestMetadata:
$ref: "#/definitions/RequestMetadata"
EmailLinkCreateArgs:
description: "Parameters to create an email magic link."
type: "object"
properties:
buttonText:
description: 'The text to display on the button in the email. It defaults to "Magic link".'
type: "string"
default: "Magic link"
example: "Login"
greeting:
description: 'The smaller text above the title.'
type: "string"
example: "Hello Jane Doe,"
logoClickURL:
description: "The URL to redirect to when the logo is clicked."
type: "string"
example: "https://example.com"
logoImageURL:
description: "The URL to the logo image to display in the email."
type: "string"
example: "https://example.com/logo.png"
serviceName:
description: "The name of your service. This is used in invisible email metadata."
type: "string"
example: "example.com"
subject:
description: 'The subject of the email. It must be between 5 and 100 characters inclusive. Make sure to include
the name of your application.'
type: "string"
example: "Login to example.com"
subTitle:
description: "The smaller text, right above the magic link button."
type: "string"
example: "Login using the button below."
title:
description: 'The larger text, right above the subtitle. It must be between 5 and 256 characters inclusive.
Make sure to include the name of your application.'
type: "string"
example: "Login to example.com with a magic link"
toEmail:
description: "The email address to send the magic link to."
type: "string"
format: "email"
example: "[email protected]"
toName:
description: "The name of the recipient."
type: "string"
example: "Jane Doe"
required:
- "subject"
- "title"
- "toEmail"
- "serviceName"
EmailLinkCreateRequest:
description: "The request body for the /email-link/create endpoint."
type: "object"
properties:
emailArgs:
$ref: "#/definitions/EmailLinkCreateArgs"
linkArgs:
$ref: "#/definitions/LinkCreateArgs"
required:
- "emailArgs"
- "linkArgs"
EmailLinkCreateResults:
description: "The results for creating an email magic link."
type: "object"
properties:
linkCreateResults:
$ref: "#/definitions/LinkCreateResults"
EmailLinkCreateResponse:
description: "The response body from the /email-link/create endpoint."
type: "object"
properties:
emailLinkCreateResults:
$ref: "#/definitions/EmailLinkCreateResults"
requestMetadata:
$ref: "#/definitions/RequestMetadata"
ServiceAccountCreateArgs:
description: "Parameters to create a service account."
type: "object"
properties:
serviceLogo:
description: "The URL of the service account's service's logo."
type: "string"
format: "uri"
serviceName:
description: "The name of the service account's service."
type: "string"
serviceURL:
description: "The landing page URL for the service account's service."
type: "string"
format: "uri"
ServiceAccountCreateRequest:
description: "The request body for the /admin/service-account/create endpoint."
type: "object"
properties:
createServiceAccountArgs:
$ref: "#/definitions/ServiceAccountCreateArgs"
required:
- "createServiceAccountArgs"
ServiceAccountCreateResults:
description: "The results for creating a service account."
type: "object"
properties:
serviceAccount:
description: "The service account that was created."
$ref: "#/definitions/ServiceAccount"
ServiceAccountCreateResponse:
description: "The response body for the /admin/service-account/create endpoint."
type: "object"
properties:
serviceAccountCreateResults:
$ref: "#/definitions/ServiceAccountCreateResults"
requestMetadata:
$ref: "#/definitions/RequestMetadata"
securityDefinitions:
apiKey:
type: "apiKey"
in: "header"
name: "X-API-KEY"
security:
- apiKey: [ ]
tags:
- name: "admin"
description: "Endpoints for service accounts authorized with an admin API key."