-
Notifications
You must be signed in to change notification settings - Fork 10
/
apiary.apib
229 lines (169 loc) · 6.46 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
FORMAT: 1A
HOST: http://verify:3000/
# Jincor VERIFY Service
Jincor Verification is a service for verify users email, phone, and etc.
The main responsibilities are:
1. Interact with a service provider
1. Validation of a received code
# API Endpoints Summary
JWT_TOKEN should be passed for every API call in the HTTP headers,
that was received from auth service.
1. `/methods/{METHOD}/actions/initiate [POST]`
1. `/methods/{METHOD}/verifiers/{VERIFICATION_ID}/actions/validate [POST]`
1. `/methods/{METHOD}/verifiers/{VERIFICATION_ID} [DELETE]`
# Notes about google_auth
1. When you initiate google_auth verification 1st time for selected consumer you will get `totpUri` to show QR code in your frontend app.
2. The received secret will be **TEMPORARY** until you verify it first time. If secret is not verified at least 1 time and you `initiate` new google_auth verification for consumer - you will get **NEW** secret. It's required to ensure that user successfully stored the secret and entered correct code.
3. When you want to disable 2FA - initiate verification and send `removeSecret=true` param to `validate` endpoint to remove consumer's secret.
## Verification: Initiate [/methods/{METHOD}/actions/initiate]
Initiate verification process, with usage of specified *METHOD*.
+ Parameters
+ METHOD (string) - One of *email*, *google_auth*, *phone* (not implemented).
### Initiate verification [POST]
Example: email verification `/methods/email/actions/initiate`.
Pass uuid in `policy.forcedVerificationId` to force using of your verification generated id.
Set up own code in `policy.forcedCode` to force using of your verification code (does not apply for google_auth method).
+ Request (application/json)
+ Headers
Authorization: Bearer {JWT_TOKEN}
Accept: application/vnd.jincor+json; version=1
+ Body
{
"consumer": "test@test.com",
"issuer": "Jincor",
"template": {
"body": "Click on the <a href=\"https://service/verify-email/5RkvAr0PUe708a?code={{{CODE}}}&verificationId={{{VERIFICATION_ID}}}\">Verify Link</a> to continue registration."
},
"generateCode": {
"length": 32,
"symbolSet": ["DIGITS", "alphas", "ALPHAS"]
},
"policy": {
"expiredOn": "01:00:00"
},
"payload": {
"your": "custom payload"
}
}
+ Response 200 (application/json)
{
"status": 200,
"verificationId": "dc910ae0-7c67-4ace-8ebb-9edd4b5d8b0f",
"attempts": 0,
"expiredOn": 1505817462,
"payload": {
"your": "custom payload"
}
}
+ Response 200 (application/json)
{
"verificationId": "5028c0cd-07a9-4fa7-8d88-49edd2a44b72",
"consumer": "test@test.com",
"expiredOn": 1508689744,
"totpUri": "otpauth://totp/:test@test.com?secret=CK53DOA3R7B2ZDMZKVOM53ZPT355ORJI&issuer=&algorithm=SHA1&digits=6&period=30",
"status": 200
}
+ Response 404 (application/json)
{
"status": 404,
"error": "Method not supported"
}
+ Response 422 (application/json)
{
"status": 422,
"error": "Invalid request",
"details": [
{"path": "generateCode.length", "error": "Incorrect number format"}
]
}
## Verification: Validate [/methods/{METHOD}/verifiers/{VERIFICATION_ID}/actions/validate]
+ Parameters
+ METHOD (string) - One of *phone*, *email*, *google_auth*.
+ VERIFICATION_ID (string)
### Validate the code [POST]
Example: code validation for the email
method `/methods/email/verifiers/dc910ae0-7c67-4ace-8ebb-9edd4b5d8b0f/actions/validate`.
+ code `1234qwertA` (required)
+ removeSecret `true` (optional - use it to remove secret when you want to disable 2FA for consumer)
+ Request (application/json)
+ Headers
Authorization: Bearer {JWT_TOKEN}
Accept: application/vnd.jincor+json; version=1
+ Body
{
"code": "JeDknKO0EZRBT6aFPrFQhzcCA2aqyVsHzZeJ8Vf",
"removeSecret": true
}
+ Response 200 (application/json)
{
"status": 200,
"data": {
"verificationId": "dc910ae0-7c67-4ace-8ebb-9edd4b5d8b0f",
"consumer": "test@test.com",
"expiredOn": 1505817462,
"payload": {
"your": "custom payload"
},
"attempts": 0
}
}
+ Response 404 (application/json)
{
"status": 404,
"error": "Not found"
}
+ Response 422 (application/json)
{
"status": 422,
"error": "Invalid code",
"data": {
"verificationId": "dc910ae0-7c67-4ace-8ebb-9edd4b5d8b0f",
"consumer": "test@test.com",
"expiredOn": 1505817462,
"payload": {
"your": "custom payload"
},
"attempts": 1
}
}
## Verifications [/methods/{METHOD}/verifiers/{VERIFICATION_ID}]
+ Parameters
+ METHOD (string) - One of *phone*, *email*, *google_auth*.
+ VERIFICATION_ID (string)
### Get verification [GET]
+ Request (application/json)
+ Headers
Authorization: Bearer {JWT_TOKEN}
Accept: application/vnd.jincor+json; version=1
+ Response 200 (application/json)
{
"status": 200,
"data": {
"verificationId": "dc910ae0-7c67-4ace-8ebb-9edd4b5d8b0f",
"consumer": "test@test.com",
"expiredOn": 1505817462,
"payload": {
"your": "custom payload"
},
"attempts": 1
}
}
+ Response 404 (application/json)
{
"status": 404,
"error": "Not found"
}
### Invalidate the code [DELETE]
+ Request (application/json)
+ Headers
Authorization: Bearer {JWT_TOKEN}
Accept: application/vnd.jincor+json; version=1
+ Response 200 (application/json)
{
"status": 200
}
+ Response 404 (application/json)
{
"status": 404,
"error": "Not found"
}