-
Notifications
You must be signed in to change notification settings - Fork 23
/
openapi.yaml
408 lines (408 loc) · 14 KB
/
openapi.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
openapi: 3.0.1
info:
title: Firefox Guardian API
description: API to manage Guardian accounts, devices and servers
version: "0.1"
servers:
- url: "https://guardian-dev.herokuapp.com"
description: Development server
- url: "http://localhost:3000"
description: Local server
paths:
/api/v1/vpn/account:
get:
summary: Account Information
description: Returns information about the user, their devices and subscription status.
security:
- bearerAuth: []
responses:
"200":
description: 200 response
content:
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/AccountDetails"
example:
email: johndoe@example.com
display_name: John Doe
avatar: https://example.com/avatar.jpg
subscriptions:
vpn:
active: true
created_at: "2019-08-01T10:22:16.853Z"
renews_on: "2019-08-01T10:22:16.853Z"
devices:
- name: Windows-4242
pubkey: veGD6/aEY6sMfN3Ls7YWPmNgu3AheO7nQqsFT47YSws=
ipv4_address: 10.99.0.1/32
ipv6_address: fc00:bbbb:bbbb:bb01::1/128
created_at: "2019-08-01T10:22:16.853Z"
- name: Android-2424
pubkey: j38fC/fjlkdDFSAFFGDKLVCASDCLDKFLDSCsfdslaDs=
pv4_address: 10.99.0.1/32
ipv6_address: fc00:bbbb:bbbb:bb01::1/128
created_at: "2019-08-01T10:22:16.853Z"
max_devices: 5
"401":
$ref: "#/components/responses/UnauthorizedError"
/api/v1/vpn/device:
post:
summary: Add Device
description: Adds a new device to the user's account.
security:
- bearerAuth: []
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: Human friendly name of the device.
pubkey:
type: string
description: Public key of the device.
required:
- name
- pubkey
example:
name: Windows-4242
pubkey: veGD6/aEY6sMfN3Ls7YWPmNgu3AheO7nQqsFT47YSws=
responses:
"201":
description: Device added successfully.
content:
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/GuardianDevice"
example:
name: Windows-4242
pubkey: veGD6/aEY6sMfN3Ls7YWPmNgu3AheO7nQqsFT47YSws=
ipv4_address: 10.99.0.1/32
ipv6_address: fc00:bbbb:bbbb:bb01::1/128
created_at: "2019-08-01T10:22:16.853Z"
"400":
$ref: "#/components/responses/GuardianAddDeviceError"
"401":
$ref: "#/components/responses/UnauthorizedError"
/api/v1/vpn/device/{pubkey}:
delete:
summary: Remove Device
description: Removes a device from a user's account
security:
- bearerAuth: []
parameters:
- name: pubkey
in: path
schema:
type: string
required: true
description: The WireGuard public key, urlencoded.
example: veGD6%2FaEY6sMfN3Ls7YWPmNgu3AheO7nQqsFT47YSws%3D
responses:
"204":
description: Device removed successfully.
"400":
$ref: "#/components/responses/GuardianDeleteDeviceError"
"401":
$ref: "#/components/responses/UnauthorizedError"
/api/v1/vpn/servers:
get:
summary: List Servers
description: Returns a list of wireguard servers.
security:
- bearerAuth: []
responses:
"200":
description: 200 response. The schema is defined by Mullvad API.
content:
application/json; charset=utf-8:
schema:
type: object
"401":
$ref: "#/components/responses/UnauthorizedError"
/api/v1/vpn/versions:
get:
summary: App Versions
description: Returns the versions of the client apps
responses:
"200":
description: 200 response
content:
application/json; charset=utf-8:
schema:
type: object
properties:
windows:
type: object
properties:
latest:
type: object
description: Latest version of the client.
minimum:
type: object
description: Minimum version the client must be at.
properties:
version:
type: string
description: The version string
released_on:
type: string
description: The release date
message:
type: string
description: (optional) release message
example:
windows:
latest:
version: "1.0"
released_on: "2019-08-01T10:22:16.853Z"
message: Our first real release. Get it while it's hot!
minimum:
version: "0.1"
released_on: "2019-08-01T10:22:16.853Z"
message: Our first alpha release!
/api/v1/vpn/login:
post:
summary: Token-based authentication flow.
description: This endpoint returns urls, an expiration and poll interval for token-based authentication.
responses:
"200":
description: 200 response
content:
application/json; charset=utf-8:
schema:
type: object
properties:
login_url:
type: string
description: URL to open in the user's browser
verification_url:
type: string
description: URL to poll for authentication status
expires_on:
type: string
description: The expiration date for the URLs
poll_interval:
type: number
description: Poll interval in seconds
example:
login_url: https://guardian-dev.herokuapp.com/oauth/client/login/token-1234567890
verification_url: https://guardian-dev.herokuapp.com/v1/vpn/login/verify/token-1234567890
expires_on: "2019-08-01T10:22:16.853Z"
poll_interval: 20
/v1/vpn/login/verify/{token}:
get:
summary: Check authentication status.
parameters:
- name: token
in: path
schema:
type: string
required: true
description: The authentication token.
example:
responses:
"200":
description: 200 response. Successful authentication.
content:
application/json; charset=utf-8:
schema:
type: object
properties:
user:
$ref: "#/components/schemas/AccountDetails"
token:
type: string
description: API authentication token
example:
user:
email: johndoe@example.com
display_name: John Doe
avatar: https://example.com/avatar.jpg
subscriptions:
vpn:
active: true
created_at: "2019-08-01T10:22:16.853Z"
renews_on: "2019-08-01T10:22:16.853Z"
devices:
- name: Windows-4242
pubkey: veGD6/aEY6sMfN3Ls7YWPmNgu3AheO7nQqsFT47YSws=
ipv4_address: 10.99.0.1/32
ipv6_address: fc00:bbbb:bbbb:bb01::1/128
created_at: "2019-08-01T10:22:16.853Z"
- name: Android-2424
pubkey: j38fC/fjlkdDFSAFFGDKLVCASDCLDKFLDSCsfdslaDs=
pv4_address: 10.99.0.1/32
ipv6_address: fc00:bbbb:bbbb:bb01::1/128
created_at: "2019-08-01T10:22:16.853Z"
max_devices: 5
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJycm9zYXJpb0Btb3ppbGxhLmNvbSIsImRldmljZV91aWQiOiIzYmI1NDk4MC0yYmQ4LTQ4ODctOTI2OS1lMjlmYWNhNjU0ZWMiLCJpYXQiOjE1NjczNzAyMDN9.pF9tVYmfcuFW-7PdK7NrsczxbchLag9kSRYimN8kW0U
"401":
$ref: "#/components/responses/AuthenticationError"
components:
securitySchemes:
bearerAuth:
description: The client must send token as "Bearer <token>" in the Authorization header
type: http
scheme: bearer
bearerFormat: JWT
schemas:
ErrorSchema:
type: object
properties:
code:
type: integer
description: The HTTP status code.
errno:
type: integer
description: The error number.
error:
type: string
description: The error message.
GuardianDevice:
type: object
properties:
name:
type: string
description: Human friendly name of the device.
pubkey:
type: string
description: The WireGuard public key for the device.
ipv4_address:
type: string
description: The ipv4 peer adress for WireGuard. Note that the mask may be bigger then a single IP.
ipv6_address:
type: string
description: The ipv6 peer address for WireGuard. Note that the mask may be bigger then a single IP.
created_at:
type: string
description: Datetime when the device first authenticated.
AccountDetails:
type: object
properties:
email:
type: string
display_name:
type: string
description: User defined display name. Empty string for users that haven't set one.
avatar:
type: string
subcriptions:
type: object
description: Subscriptions information
properties:
vpn:
type: object
description: The VPN Subscription information
properties:
active:
type: boolean
description: Is the VPN subscription active?
created_at:
type: string
renews_on:
type: string
devices:
type: array
description: List of devices
items:
$ref: "#/components/schemas/GuardianDevice"
max_devices:
type: number
description: Maximum number of devices for this user
responses:
GuardianAddDeviceError:
description: Guardian Add Device Error
content:
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/ErrorSchema"
examples:
MissingPubkeyError:
value:
code: 400
errno: 100
error: "Missing argument: 'pubkey'"
MissingNameError:
value:
code: 400
errno: 101
error: "Missing argument: 'name'"
InvalidPubkeyError:
value:
code: 400
errno: 102
error: "'pubkey' is not a valid WireGuard public key"
PubkeyAlreadyUsed:
value:
code: 400
errno: 103
error: WireGuard public key already used by other account
KeyLimitReachedError:
value:
code: 400
errno: 104
error: An account can only have up to 5 pubkeys
GuardianDeleteDeviceError:
description: Guardian Delete Device Error
content:
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/ErrorSchema"
examples:
PubkeyNotFound:
value:
code: 404
errno: 105
error: "A device with that 'pubkey' does not exist"
UnauthorizedError:
description: Access token is missing or invalid
content:
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/ErrorSchema"
examples:
InvalidToken:
value:
code: 401
errno: 120
error: invalid token
UserNotFound:
value:
code: 401
errno: 121
error: User not found
DeviceNotFound:
value:
code: 401
errno: 122
error: Device not found
NoActiveSubscription:
value:
code: 401
errno: 123
error: "User doesn't have an active subscription"
AuthenticationError:
description: Client authentication token is missing, unverified or expired
content:
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/ErrorSchema"
examples:
LoginTokenNotFound:
value:
code: 401
errno: 124
error: Login token not found
LoginTokenExpired:
value:
code: 401
errno: 125
error: Login token expired
LoginTokenUnverified:
value:
code: 401
errno: 126
error: Login token isn't verified