Debian Codegraph @

docs/openapi.yaml

raw
1 openapi: 3.0.3
2 info:
3 description: |
4 Default API for Flask-Security.
5
6 __N.B. This is preliminary.__
7
8 Since Flask-Security is middleware, with many possible configurations this is a
9 guide to how the APIs will behave using standard defaults.
10
11 By default, all POST requests require a CSRF token. This is handled automatically
12 if you render the form from your Flask application. If you send JSON, then you must include a request header (configured via __SECURITY_CSRF_HEADER__).
13 Please read the online documentation to find out details on how CSRF can be configured.
14
15 You can download the latest spec from: https://github.com/pallets-eco/flask-security/blob/main/docs/openapi.yaml
16 version: 2.0.0
17 title: "Flask-Security External API"
18 contact:
19 name: Flask-Security
20 url: https://github.com/pallets-eco/flask-security
21 license:
22 name: MIT
23 url: https://github.com/pallets-eco/flask-security/blob/main/LICENSE
24 paths:
25 /login:
26 get:
27 summary: GET login form and/or user information
28 responses:
29 200:
30 description: >
31 Login form or user information. The JSON response will always
32 carry the csrf_token information.
33 If SECURITY_CSRF_COOKIE_NAME is set then a cookie with the csrf token will be set.
34 If the caller is already authenticated, then
35 additional information is returned for JSON requests.
36 This can be very useful for single-page applications where during a force refresh, all state is lost.
37 By performing this GET, the session cookie will authenticate the user and the response will contain user information.
38 content:
39 text/html:
40 schema:
41 type: string
42 description: render_template(SECURITY_LOGIN_USER_TEMPLATE)
43 example: render_template(SECURITY_LOGIN_USER_TEMPLATE)
44 application/json:
45 schema:
46 allOf:
47 - $ref: '#/components/schemas/DefaultJsonResponse'
48 - type: object
49 properties:
50 response:
51 type: object
52 properties:
53 identity_attributes:
54 type: array
55 description: List of allowable identities
56 items:
57 type: string
58 302:
59 description: Response when already logged in (non-JSON request)
60 headers:
61 Location:
62 description: Redirect to ``SECURITY_POST_LOGIN_VIEW``
63 schema:
64 type: string
65 format: uri
66 post:
67 summary: Login to application
68 description: Supports both json and form request types. If the caller is already logged in, then in the form case, they are redirected to SECURITY_POST_LOGIN_VIEW, for a json request, a 400 is returned.
69 parameters:
70 - name: next
71 in: query
72 description: >
73 URL to redirect to on successful login. Ignored for json request.
74 schema:
75 type: string
76 - $ref: "#/components/parameters/include_auth_token"
77 requestBody:
78 required: true
79 content:
80 application/json:
81 schema:
82 $ref: "#/components/schemas/Login"
83 application/x-www-form-urlencoded:
84 schema:
85 $ref: "#/components/schemas/Login"
86 responses:
87 200:
88 description: Login response
89 content:
90 application/json:
91 schema:
92 allOf:
93 - description: >
94 The user successfully signed in using their primary credential.
95 Note that depending on SECURITY_TWO_FACTOR configuration variable, a second form of authentication might be required prior to the user being fully authenticated.
96 `tf_required` will be set to True in this case.
97 Note that if 2FA is not configured, only the ``tf_required`` property (=False) will be returned.
98 - $ref: "#/components/schemas/LoginJsonResponse"
99 text/html:
100 schema:
101 description: Unsuccessful login
102 type: string
103 example: render_template(SECURITY_LOGIN_USER_TEMPLATE) with error values
104 302:
105 description: >
106 If the caller is already authenticated, the form contents is ignored and a
107 redirect is done: redirect(SECURITY_POST_LOGIN_VIEW) (note that 'next' is ignored).
108
109 If the caller is NOT already authenticated, and the form contents are
110 validated the caller will be redirected to:
111 redirect(next) or redirect(SECURITY_POST_LOGIN_VIEW)
112 headers:
113 Location:
114 description: Redirect to ``SECURITY_POST_LOGIN_VIEW``
115 schema:
116 type: string
117 400:
118 description: Errors while validating login, or caller already authenticated/logged in.
119 content:
120 application/json:
121 schema:
122 $ref: "#/components/schemas/DefaultJsonErrorResponse"
123 /login(passwordless):
124 get:
125 summary: GET passwordless login form
126 responses:
127 200:
128 description: Passwordless login form
129 content:
130 text/html:
131 schema:
132 type: string
133 example: render_template(SECURITY_SEND_LOGIN_TEMPLATE)
134 post:
135 summary: Send passwordless login instructions email
136 requestBody:
137 required: true
138 content:
139 application/json:
140 schema:
141 $ref: "#/components/schemas/EmailLink"
142 application/x-www-form-urlencoded:
143 schema:
144 $ref: "#/components/schemas/EmailLink"
145 responses:
146 200:
147 description: >
148 Passwordless login response. For forms both success and validation errors.
149 content:
150 text/html:
151 schema:
152 description: Passwordless login form - with errors.
153 type: string
154 example: render_template(SECURITY_SEND_LOGIN_TEMPLATE)
155 application/json:
156 schema:
157 $ref: "#/components/schemas/DefaultJsonResponse"
158 400:
159 description: Errors while validating form
160 content:
161 application/json:
162 schema:
163 $ref: "#/components/schemas/DefaultJsonErrorResponse"
164 /login(passwordless)/{token}:
165 parameters:
166 - name: token
167 in: path
168 required: true
169 schema:
170 type: string
171 get:
172 summary: Login via token
173 description: >
174 This is the result of getting a passwordless login token and is usually
175 the result of clicking the link from a passwordless email.
176 This ALWAYS results in a 302 redirect.
177 responses:
178 302:
179 description: >
180 Redirects depending on success/error and whether
181 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'.
182 headers:
183 Location:
184 description: |
185 On spa-success: SECURITY_POST_LOGIN_VIEW?identity={identity}&email={email}
186
187 On spa-error-expired: SECURITY_LOGIN_ERROR_VIEW?error={msg}&identity={identity}&email={email}
188
189 On spa-error-invalid-token: SECURITY_LOGIN_ERROR_VIEW?error={msg}
190
191 On form-success: SECURITY_POST_LOGIN_VIEW
192
193 On form-error-expired: SECURITY_LOGIN_VIEW
194
195 On form-error-invalid-token: SECURITY_LOGIN_VIEW
196 schema:
197 type: string
198 /logout:
199 get:
200 summary: Log out current user
201 responses:
202 302:
203 description: Successful logout
204 headers:
205 Location:
206 description: Redirect to ``SECURITY_POST_LOGOUT_VIEW``
207 schema:
208 type: string
209 post:
210 summary: Log out current user
211 responses:
212 200:
213 description: Successful logout
214 content:
215 application/json:
216 schema:
217 type: object
218 required: [meta]
219 properties:
220 meta:
221 type: object
222 required: [code]
223 properties:
224 code:
225 type: integer
226 example: 200
227 description: Http status code
228 /verify:
229 get:
230 summary: GET verify/reauthentication form
231 description: >
232 If an endpoint is protected with @auth_required() with a freshness declaration
233 this endpoint will be called to request an already signed in user to reauthenticate.
234 responses:
235 200:
236 description: Verify/reauthenticate form
237 content:
238 text/html:
239 schema:
240 type: string
241 description: render_template(SECURITY_VERIFY_TEMPLATE)
242 example: render_template(SECURITY_VERIFY_TEMPLATE)
243 application/json:
244 schema:
245 type: object
246 properties:
247 has_webauthn_verify_credential:
248 type: boolean
249 description: <
250 True if caller has a registered WebAuthn Key which has a `usage` that
251 is allowed by the SECURITY_WAN_ALLOW_AS_VERIFY configuration setting.
252 oauth_enabled:
253 type: boolean
254 description: True if SECURITY_OAUTH_ENABLE is True
255 oauth_providers:
256 type: array
257 items:
258 type: string
259 description: A list of OAuth providers that have been registered.
260 post:
261 summary: Verify/Reauthentication
262 parameters:
263 - $ref: "#/components/parameters/include_auth_token"
264 requestBody:
265 required: true
266 content:
267 application/json:
268 schema:
269 $ref: "#/components/schemas/Verify"
270 application/x-www-form-urlencoded:
271 schema:
272 $ref: "#/components/schemas/Verify"
273 responses:
274 200:
275 description: Verify/Reauthenticate response.
276 content:
277 application/json:
278 schema:
279 allOf:
280 - description: >
281 The user successfully reauthenticated.
282 - $ref: "#/components/schemas/JsonResponseWithToken"
283 text/html:
284 schema:
285 description: Unsuccessful reauthentication.
286 type: string
287 example: render_template(SECURITY_VERIFY_TEMPLATE) with error values
288 302:
289 description: User successfully reauthenticated when using form based request.
290 headers:
291 Location:
292 description: Redirect to ``next`` or ``SECURITY_POST_VERIFY_VIEW``
293 schema:
294 type: string
295 400:
296 description: Errors while validating attributes.
297 content:
298 application/json:
299 schema:
300 $ref: "#/components/schemas/DefaultJsonErrorResponse"
301 /register:
302 get:
303 summary: GET register form
304 responses:
305 200:
306 description: Register form
307 content:
308 text/html:
309 schema:
310 type: string
311 description: render_template(SECURITY_REGISTER_USER_TEMPLATE)
312 example: render_template(SECURITY_REGISTER_USER_TEMPLATE)
313 302:
314 description: Response when already logged in
315 headers:
316 Location:
317 description: Redirect to ``SECURITY_POST_LOGIN_VIEW``
318 schema:
319 type: string
320 post:
321 summary: Register new user with application
322 parameters:
323 - name: next
324 in: query
325 description: >
326 URL to redirect to on successful registration. Ignored for json request.
327 schema:
328 type: string
329
330 requestBody:
331 required: true
332 content:
333 application/json:
334 schema:
335 $ref: "#/components/schemas/Register"
336 application/x-www-form-urlencoded:
337 schema:
338 $ref: "#/components/schemas/RegisterForm"
339 responses:
340 200:
341 description: Register response
342 content:
343 application/json:
344 schema:
345 $ref: "#/components/schemas/DefaultJsonResponse"
346 text/html:
347 schema:
348 description: Unsuccessful registration
349 type: string
350 example: render_template(SECURITY_REGISTER_USER_TEMPLATE) with error values
351 302:
352 description: >
353 Successful registration with form data body.
354 headers:
355 Location:
356 description: redirect to ``next`` or ``SECURITY_POST_REGISTER_VIEW``
357 schema:
358 type: string
359 400:
360 description: Errors while validating registration form
361 content:
362 application/json:
363 schema:
364 $ref: "#/components/schemas/DefaultJsonErrorResponse"
365 /change:
366 get:
367 summary: GET change password form
368 responses:
369 200:
370 description: change password form
371 content:
372 text/html:
373 schema:
374 type: string
375 description: render_template(SECURITY_CHANGE_PASSWORD_TEMPLATE)
376 example: render_template(SECURITY_CHANGE_PASSWORD_TEMPLATE)
377 application/json:
378 schema:
379 allOf:
380 - $ref: '#/components/schemas/DefaultJsonResponse'
381 - type: object
382 properties:
383 response:
384 type: object
385 properties:
386 active_password:
387 type: boolean
388 description: Does user already have a password?
389 post:
390 summary: Change password
391 parameters:
392 - name: X-XSRF-Token
393 in: header
394 schema:
395 $ref: "#/components/headers/X-CSRF-Token"
396 - $ref: "#/components/parameters/include_auth_token"
397 requestBody:
398 required: true
399 content:
400 application/json:
401 schema:
402 $ref: "#/components/schemas/ChangePassword"
403 application/x-www-form-urlencoded:
404 schema:
405 $ref: "#/components/schemas/ChangePassword"
406 responses:
407 200:
408 description: Change password response.
409 content:
410 text/html:
411 schema:
412 description: Change form validation error.
413 type: string
414 example: render_template(SECURITY_CHANGE_PASSWORD_TEMPLATE) with error values
415 application/json:
416 schema:
417 $ref: "#/components/schemas/JsonResponseWithToken"
418 302:
419 description: Password has been changed (non-json)
420 headers:
421 Location:
422 description: |
423 On success: Redirect to ``SECURITY_POST_CHANGE_VIEW`` or
424 ``SECURITY_POST_LOGIN_VIEW``
425 schema:
426 type: string
427 400:
428 description: Errors while validating form
429 content:
430 application/json:
431 schema:
432 $ref: "#/components/schemas/DefaultJsonErrorResponse"
433 /change-email:
434 get:
435 summary: GET change email form
436 responses:
437 200:
438 description: change email form
439 content:
440 text/html:
441 schema:
442 type: string
443 description: render_template(SECURITY_CHANGE_EMAIL_TEMPLATE)
444 example: render_template(SECURITY_CHANGE_EMAIL_TEMPLATE)
445 application/json:
446 schema:
447 allOf:
448 - $ref: '#/components/schemas/DefaultJsonResponse'
449 - type: object
450 properties:
451 response:
452 type: object
453 properties:
454 current_email:
455 type: string
456 description: User's currently registered email
457 post:
458 summary: Generate and send change email confirmation link
459 requestBody:
460 required: true
461 content:
462 application/json:
463 schema:
464 $ref: "#/components/schemas/ChangeEmail"
465 application/x-www-form-urlencoded:
466 schema:
467 $ref: "#/components/schemas/ChangeEmail"
468 responses:
469 200:
470 description: Change email response.
471 content:
472 text/html:
473 schema:
474 description: |
475 Change email form (errors or not).
476 If no errors then a confirmation instructions (with link) has been sent to the
477 requested (new) email.
478 type: string
479 example: render_template(SECURITY_CHANGE_EMAIL_TEMPLATE) with error values
480 application/json:
481 schema:
482 $ref: "#/components/schemas/DefaultJsonResponse"
483 400:
484 description: Errors while validating form
485 content:
486 application/json:
487 schema:
488 allOf:
489 - $ref: '#/components/schemas/DefaultJsonErrorResponse'
490 - type: object
491 properties:
492 response:
493 type: object
494 properties:
495 current_email:
496 type: string
497 description: User's currently registered email
498 /change-email/{token}:
499 parameters:
500 - name: token
501 in: path
502 required: true
503 schema:
504 type: string
505 get:
506 summary: Confirm change of user's registered email
507 description: >
508 This is the result of getting a change-email token and is usually
509 the result of clicking the link from a change-email email.
510 This always results in a redirect().
511 responses:
512 302:
513 description: >
514 Redirects depending on success/error and whether
515 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'.
516 headers:
517 Location:
518 description: |
519 On spa-success: SECURITY_POST_CHANGE_EMAIL_VIEW?success={SECURITY_MSG_CHANGE_EMAIL_CONFIRMED}
520
521 On spa-error-expired: SECURITY_CHANGE_EMAIL_ERROR_VIEW?error={SECURITY_MSG_CHANGE_EMAIL_EXPIRED}
522
523 On spa-error-invalid-token: SECURITY_CHANGE_EMAIL_ERROR_VIEW?error={SECURITY_MSG_API_ERROR}
524
525 On default-error: SECURITY_CHANGE_EMAIL_ERROR_VIEW || .change_email
526
527 On default-success: SECURITY_POST_CHANGE_EMAIL_VIEW || SECURITY_POST_LOGIN_VIEW
528 schema:
529 type: string
530
531 /change-username:
532 get:
533 summary: GET change username form
534 responses:
535 200:
536 description: change username form
537 content:
538 text/html:
539 schema:
540 type: string
541 description: render_template(SECURITY_CHANGE_USERNAME_TEMPLATE)
542 example: render_template(SECURITY_CHANGE_USERNAME_TEMPLATE)
543 application/json:
544 schema:
545 allOf:
546 - $ref: '#/components/schemas/DefaultJsonResponse'
547 - type: object
548 properties:
549 response:
550 type: object
551 properties:
552 current_username:
553 type: string
554 description: Current username
555 post:
556 summary: Change username
557 parameters:
558 - name: X-XSRF-Token
559 in: header
560 schema:
561 $ref: "#/components/headers/X-CSRF-Token"
562 requestBody:
563 required: true
564 content:
565 application/json:
566 schema:
567 $ref: "#/components/schemas/ChangeUsername"
568 application/x-www-form-urlencoded:
569 schema:
570 $ref: "#/components/schemas/ChangeUsername"
571 responses:
572 200:
573 description: Change username response.
574 content:
575 text/html:
576 schema:
577 description: Form validation error.
578 type: string
579 example: render_template(SECURITY_CHANGE_USERNAME_TEMPLATE) with error values
580 application/json:
581 schema:
582 $ref: "#/components/schemas/DefaultJsonResponse"
583 302:
584 description: Username has been changed (non-json)
585 headers:
586 Location:
587 description: |
588 On success: Redirect to ``SECURITY_POST_CHANGE_USERNAME_VIEW`` or
589 ``SECURITY_POST_LOGIN_VIEW``
590 schema:
591 type: string
592 400:
593 description: Errors while validating form
594 content:
595 application/json:
596 schema:
597 $ref: "#/components/schemas/DefaultJsonErrorResponse"
598 /reset:
599 get:
600 summary: GET reset password form
601 responses:
602 200:
603 description: Reset password form
604 content:
605 text/html:
606 schema:
607 type: string
608 description: render_template(SECURITY_FORGOT_PASSWORD_TEMPLATE)
609 example: render_template(SECURITY_FORGOT_PASSWORD_TEMPLATE)
610 post:
611 summary: Send reset password instructions email
612 requestBody:
613 required: true
614 content:
615 application/json:
616 schema:
617 $ref: "#/components/schemas/EmailLink"
618 application/x-www-form-urlencoded:
619 schema:
620 $ref: "#/components/schemas/EmailLink"
621 responses:
622 200:
623 description: >
624 Reset password response. For forms both success and validation errors.
625 content:
626 text/html:
627 schema:
628 description: Forgot password form - with errors.
629 type: string
630 example: render_template(SECURITY_FORGOT_PASSWORD_TEMPLATE)
631 application/json:
632 schema:
633 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
634 302:
635 description: >
636 Response when valid email however user hasn't confirmed and
637 __SECURITY_REQUIRES_CONFIRMATION_ERROR_VIEW__ is set.
638 headers:
639 Location:
640 description: redirect(REQUIRES_CONFIRMATION_ERROR_VIEW)
641 schema:
642 type: string
643 400:
644 description: Errors while validating form
645 content:
646 application/json:
647 schema:
648 $ref: "#/components/schemas/DefaultJsonErrorResponse"
649 /reset/{token}:
650 parameters:
651 - name: token
652 in: path
653 required: true
654 schema:
655 type: string
656 get:
657 summary: Request to reset password
658 description: >
659 This is the result of getting a reset-password token and is usually
660 the result of clicking the link from a reset-password email.
661 If __SECURITY_REDIRECT_BEHAVIOR__ == 'spa' then a 302 is always returned.
662 responses:
663 200:
664 description: Reset password form
665 content:
666 text/html:
667 schema:
668 type: string
669 example: render_template(SECURITY_RESET_PASSWORD_TEMPLATE)
670 302:
671 description: >
672 Redirects depending on success/error and whether
673 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'.
674 headers:
675 Location:
676 description: |
677 On spa-success: SECURITY_RESET_VIEW?token={token}
678
679 On spa-error-expired: SECURITY_RESET_ERROR_VIEW?error={msg}
680
681 On spa-error-invalid-token: SECURITY_RESET_ERROR_VIEW?error={msg}
682
683 On default-error: redirect(SECURITY_FORGOT_PASSWORD)
684 schema:
685 type: string
686 post:
687 summary: Reset password
688 requestBody:
689 required: true
690 content:
691 application/json:
692 schema:
693 $ref: "#/components/schemas/ResetPassword"
694 application/x-www-form-urlencoded:
695 schema:
696 $ref: "#/components/schemas/ResetPassword"
697 responses:
698 200:
699 description: Reset response
700 content:
701 text/html:
702 schema:
703 description: Reset form validation error.
704 type: string
705 example: render_template(SECURITY_RESET_PASSWORD_TEMPLATE) with error values
706 application/json:
707 schema:
708 $ref: "#/components/schemas/BaseJsonResponse"
709 302:
710 description: Password has been reset or validation error (non-json)
711 headers:
712 Location:
713 description: |
714 On success: redirect(SECURITY_POST_RESET_VIEW) or
715 redirect(".login")
716
717 On invalid/expired token: redirect(SECURITY_FORGOT_PASSWORD)
718 schema:
719 type: string
720 400:
721 description: Errors while validating form
722 content:
723 application/json:
724 schema:
725 $ref: "#/components/schemas/DefaultJsonErrorResponse"
726 /recover-username:
727 get:
728 summary: GET username recovery form
729 responses:
730 200:
731 description: Username recovery form
732 content:
733 text/html:
734 schema:
735 type: string
736 description: render_template(SECURITY_USERNAME_RECOVERY_TEMPLATE)
737 example: render_template(SECURITY_USERNAME_RECOVERY_TEMPLATE)
738 application/json:
739 schema:
740 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
741 post:
742 summary: Request username recovery
743 requestBody:
744 required: true
745 content:
746 application/json:
747 schema:
748 $ref: "#/components/schemas/RecoverUsername"
749 application/x-www-form-urlencoded:
750 schema:
751 $ref: "#/components/schemas/RecoverUsername"
752 responses:
753 200:
754 description: Send username recovery email
755 content:
756 text/html:
757 schema:
758 type: string
759 description: render_template(SECURITY_USERNAME_RECOVERY_TEMPLATE)
760 example: render_template(SECURITY_USERNAME_RECOVERY_TEMPLATE)
761 application/json:
762 schema:
763 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
764 400:
765 description: Error when trying to send recovery email (e.g. user doesn't exist)
766 content:
767 application/json:
768 schema:
769 $ref: "#/components/schemas/DefaultJsonErrorResponse"
770 /confirm:
771 get:
772 summary: GET send confirmation form
773 responses:
774 200:
775 description: Confirmation form
776 content:
777 text/html:
778 schema:
779 type: string
780 description: render_template(SECURITY_SEND_CONFIRMATION_TEMPLATE)
781 example: render_template(SECURITY_SEND_CONFIRMATION_TEMPLATE)
782 post:
783 summary: Send confirmation email
784 requestBody:
785 required: true
786 content:
787 application/json:
788 schema:
789 $ref: "#/components/schemas/EmailLink"
790 application/x-www-form-urlencoded:
791 schema:
792 $ref: "#/components/schemas/EmailLink"
793 responses:
794 200:
795 description: >
796 Confirmation response. For forms both success and validation errors.
797 content:
798 text/html:
799 schema:
800 description: Confirmation form - with errors.
801 type: string
802 example: render_template(SECURITY_SEND_CONFIRMATION_TEMPLATE)
803 application/json:
804 schema:
805 $ref: "#/components/schemas/DefaultJsonResponse"
806 400:
807 description: Errors while validating form
808 content:
809 application/json:
810 schema:
811 $ref: "#/components/schemas/DefaultJsonErrorResponse"
812 /confirm/{token}:
813 parameters:
814 - name: token
815 in: path
816 required: true
817 schema:
818 type: string
819 get:
820 summary: Request to confirm account
821 description: >
822 This is the result of getting a confirmation token and is usually
823 the result of clicking the link from a confirmation email.
824 This ALWAYS results in a 302 redirect.
825 By default (unless __SECURITY_AUTO_LOGIN_AFTER_CONFIRM__ == True), the user
826 denoted by the token must authenticate using normal mechanisms.
827 responses:
828 302:
829 description: >
830 Redirects depending on success/error and whether
831 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'.
832 headers:
833 Location:
834 description: |
835 On spa-success: SECURITY_POST_CONFIRM_VIEW?identity={identity}&email={email}&{level}={msg}
836
837 On spa-error-expired: SECURITY_CONFIRM_ERROR_VIEW?error={msg}
838
839 On spa-error-invalid-token: SECURITY_CONFIRM_ERROR_VIEW?error={msg}
840
841 On form-success: SECURITY_POST_CONFIRM_VIEW or
842 SECURITY_POST_LOGIN_VIEW
843
844 On form-success (no auto-login): SECURITY_POST_CONFIRM_VIEW or
845 ".login"
846
847 On form-error-expired: SECURITY_CONFIRM_ERROR_VIEW or
848 SECURITY_CONFIRM_URL
849
850 On form-error-invalid-token: SECURITY_CONFIRM_ERROR_VIEW or
851 SECURITY_CONFIRM_URL
852 schema:
853 type: string
854 /us-signin:
855 get:
856 summary: GET Unified Sign In form
857 responses:
858 200:
859 description: >
860 Sign in form
861 If SECURITY_CSRF_COOKIE_NAME is set then a cookie with the csrf token will be set.
862 If the caller is already authenticated, then
863 additional information is returned for JSON requests.
864 This can be very useful for single-page applications where during a force refresh, all state is lost.
865 By performing this GET, the session cookie will authenticate the user and the response will contain user information.
866 content:
867 text/html:
868 schema:
869 type: string
870 description: render_template(SECURITY_US_SIGNIN_TEMPLATE)
871 example: render_template(SECURITY_US_SIGNIN_TEMPLATE)
872 application/json:
873 schema:
874 allOf:
875 - $ref: '#/components/schemas/DefaultJsonResponse'
876 - type: object
877 properties:
878 available_methods:
879 type: string
880 description: Config setting SECURITY_US_ENABLED_METHODS
881 code_methods:
882 type: string
883 description: All SECURITY_US_ENABLED_METHODS that require a code to be generated and sent.
884 identity_attributes:
885 type: string
886 description: Configuration setting SECURITY_USER_IDENTITY_ATTRIBUTES
887 post:
888 summary: Unified Sign In
889 parameters:
890 - $ref: "#/components/parameters/include_auth_token"
891 requestBody:
892 required: true
893 content:
894 application/json:
895 schema:
896 $ref: "#/components/schemas/UsSignin"
897 application/x-www-form-urlencoded:
898 schema:
899 $ref: "#/components/schemas/UsSignin"
900 responses:
901 200:
902 description: Unified Sign In response
903 content:
904 application/json:
905 schema:
906 allOf:
907 - description: >
908 The user successfully signed in using their primary credentials.
909 Note that depending on the SECURITY_TWO_FACTOR and SECURITY_US_MFA_REQUIRED configuration variables, a second form of authentication might be required prior to the user being fully authenticated.
910 `tf_required` will be set to True in this case.
911 - $ref: "#/components/schemas/LoginJsonResponse"
912 text/html:
913 schema:
914 type: string
915 description: Unsuccessful sign in - render_template(SECURITY_US_SIGNIN_TEMPLATE) with error values
916 example: render_template(SECURITY_US_SIGNIN_TEMPLATE) with error values
917 302:
918 description: >
919 If the caller already authenticated, the form contents are ignored and a
920 redirect is done: redirect(SECURITY_POST_LOGIN_VIEW) (note that 'next' is ignored).
921
922 If the caller is NOT already authenticated, and the form contents are
923 validated the caller will be redirected to:
924 redirect(next) or redirect(SECURITY_POST_LOGIN_VIEW)
925 headers:
926 Location:
927 description: Redirect to ``SECURITY_POST_LOGIN_VIEW``
928 schema:
929 type: string
930 400:
931 description: Errors while validating attributes, or caller already authenticated/logged in.
932 content:
933 application/json:
934 schema:
935 $ref: "#/components/schemas/DefaultJsonErrorResponse"
936 /us-signin/send-code:
937 post:
938 summary: Send Code for unified sign in.
939 requestBody:
940 required: true
941 content:
942 application/json:
943 schema:
944 $ref: "#/components/schemas/UsSigninSendCode"
945 application/x-www-form-urlencoded:
946 schema:
947 $ref: "#/components/schemas/UsSigninSendCode"
948 responses:
949 200:
950 description: Send code response
951 content:
952 application/json:
953 schema:
954 $ref: "#/components/schemas/DefaultJsonResponse"
955 text/html:
956 schema:
957 description: Validation error, code send error, or code successfully sent
958 type: string
959 example: render_template(SECURITY_US_SIGNIN_TEMPLATE) with error values
960 400:
961 description: Errors while validating attributes.
962 content:
963 application/json:
964 schema:
965 $ref: "#/components/schemas/DefaultJsonErrorResponse"
966 500:
967 description: Error when trying to send code.
968 content:
969 application/json:
970 schema:
971 $ref: "#/components/schemas/DefaultJsonErrorResponse"
972
973 /us-verify:
974 get:
975 summary: GET Unified sign in verify/reauthentication form/information
976 description: >
977 If an endpoint is protected with @auth_required() with a freshness declaration
978 this endpoint will be called to request an already signed in user to reauthenticate.
979 responses:
980 200:
981 description: Verify/Reauthenticate form
982 content:
983 text/html:
984 schema:
985 type: string
986 description: render_template(SECURITY_US_VERIFY_TEMPLATE)
987 example: render_template(SECURITY_US_VERIFY_TEMPLATE)
988 application/json:
989 schema:
990 type: object
991 properties:
992 available_methods:
993 type: array
994 description: Config setting SECURITY_US_ENABLED_METHODS
995 items:
996 type: string
997 example: ["email", "sms"]
998 code_methods:
999 type: array
1000 description: All SECURITY_US_ENABLED_METHODS that the user has setup that require a code to be generated and sent.
1001 items:
1002 type: string
1003 example: ["sms"]
1004 has_webauthn_verify_credential:
1005 type: boolean
1006 description: <
1007 True if caller has a registered WebAuthn Key which has a `usage` that
1008 is allowed by the SECURITY_WAN_ALLOW_AS_VERIFY configuration setting.
1009 oauth_enabled:
1010 type: boolean
1011 description: True if SECURITY_OAUTH_ENABLE is True
1012 oauth_providers:
1013 type: array
1014 items:
1015 type: string
1016 description: A list of OAuth providers that have been registered.
1017 post:
1018 summary: Unified sign in verify/reauthentication
1019 parameters:
1020 - $ref: "#/components/parameters/include_auth_token"
1021 requestBody:
1022 required: true
1023 content:
1024 application/json:
1025 schema:
1026 $ref: "#/components/schemas/UsSigninVerify"
1027 application/x-www-form-urlencoded:
1028 schema:
1029 $ref: "#/components/schemas/UsSigninVerify"
1030 responses:
1031 200:
1032 description: Verify/reauthenticate response.
1033 content:
1034 application/json:
1035 schema:
1036 allOf:
1037 - description: >
1038 The user successfully reauthenticated.
1039 - $ref: "#/components/schemas/JsonResponseWithToken"
1040 text/html:
1041 schema:
1042 type: string
1043 description: Unsuccessful reauthentication - render_template(SECURITY_US_VERIFY_TEMPLATE) with error values
1044 example: render_template(SECURITY_US_VERIFY_TEMPLATE) with error values
1045 302:
1046 description: User successfully reauthenticated when using form based request.
1047 headers:
1048 Location:
1049 description: Redirect to ``next`` or ``SECURITY_POST_VERIFY_VIEW``
1050 schema:
1051 type: string
1052 400:
1053 description: Errors while validating attributes.
1054 content:
1055 application/json:
1056 schema:
1057 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1058 /us-verify/send-code:
1059 post:
1060 summary: Send Code for unified sign in verify.
1061 requestBody:
1062 required: true
1063 content:
1064 application/json:
1065 schema:
1066 $ref: "#/components/schemas/UsSigninVerifySendCode"
1067 application/x-www-form-urlencoded:
1068 schema:
1069 $ref: "#/components/schemas/UsSigninVerifySendCode"
1070 responses:
1071 200:
1072 description: Send code response
1073 content:
1074 application/json:
1075 schema:
1076 $ref: "#/components/schemas/DefaultJsonResponse"
1077 text/html:
1078 schema:
1079 description: Validation error, code send error, or code successfully sent
1080 type: string
1081 example: render_template(SECURITY_US_VERIFY_TEMPLATE) with error values
1082 400:
1083 description: Errors while validating attributes.
1084 content:
1085 application/json:
1086 schema:
1087 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1088 500:
1089 description: Error when trying to send code.
1090 content:
1091 application/json:
1092 schema:
1093 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1094 /us-setup:
1095 get:
1096 summary: GET Unified sign in setup passcode options.
1097 responses:
1098 200:
1099 description: Setup form
1100 content:
1101 text/html:
1102 schema:
1103 type: string
1104 description: render_template(SECURITY_US_SETUP_TEMPLATE)
1105 example: render_template(SECURITY_US_SETUP_TEMPLATE)
1106 application/json:
1107 schema:
1108 type: object
1109 properties:
1110 available_methods:
1111 type: array
1112 description: Config setting SECURITY_US_ENABLED_METHODS
1113 items:
1114 type: string
1115 example: ["email", "sms"]
1116 active_methods:
1117 type: array
1118 description: Methods that have already been setup.
1119 items:
1120 type: string
1121 example: ["sms"]
1122 setup_methods:
1123 type: array
1124 description: All SECURITY_US_ENABLED_METHODS that require setup.
1125 items:
1126 type: string
1127 example: ["email", "sms", "authenticator"]
1128 identity_attributes:
1129 type: array
1130 description: Configuration setting SECURITY_USER_IDENTITY_ATTRIBUTES
1131 items:
1132 type: string
1133 example: ["email"]
1134 phone:
1135 type: string
1136 description: existing configured phone number
1137 post:
1138 summary: Unified sign in setup.
1139 description: >
1140 An authenticated user can call this endpoint to update or add additional methods for authenticating (e.g. sms, authenticator app). This is controlled by application configuration settings SECURITY_US_ENABLED_METHODS. This endpoint is protected by a 'freshness' check - meaning the caller will be required to have authenticated recently. In addition, to ensure correctness, the newly setup method must be verified by sending and entering a code prior to it being permanently stored. This verification process is also time-limited.
1141 requestBody:
1142 required: true
1143 content:
1144 application/json:
1145 schema:
1146 $ref: "#/components/schemas/UsSetup"
1147 application/x-www-form-urlencoded:
1148 schema:
1149 $ref: "#/components/schemas/UsSetup"
1150 responses:
1151 200:
1152 description: Unified sign in setup response.
1153 content:
1154 application/json:
1155 schema:
1156 $ref: "#/components/schemas/UsSetupJsonResponse"
1157 text/html:
1158 schema:
1159 description: Invalid form values or verification code sent successfully and should be entered into the form.
1160 type: string
1161 example: render_template(SECURITY_US_SETUP_TEMPLATE) with error values
1162 400:
1163 description: Errors while validating attributes.
1164 content:
1165 application/json:
1166 schema:
1167 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1168 500:
1169 description: Error when trying to send code.
1170 content:
1171 application/json:
1172 schema:
1173 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1174 /us-setup/{token}:
1175 parameters:
1176 - name: token
1177 in: path
1178 required: true
1179 schema:
1180 type: string
1181 post:
1182 summary: Validate passcode sent and store setup method.
1183 requestBody:
1184 required: true
1185 content:
1186 application/json:
1187 schema:
1188 $ref: "#/components/schemas/UsSetupValidateRequest"
1189 application/x-www-form-urlencoded:
1190 schema:
1191 $ref: "#/components/schemas/UsSetupValidateRequest"
1192 responses:
1193 200:
1194 description: Successfully validated and persisted sign in method.
1195 content:
1196 application/json:
1197 schema:
1198 $ref: "#/components/schemas/UsSetupValidateJsonResponse"
1199 302:
1200 description: Redirect based on success or failure.
1201 headers:
1202 Location:
1203 description: |
1204 On form-success: SECURITY_US_POST_SETUP_VIEW
1205
1206 On form-error: .us-setup
1207
1208 Form errors include bad code, expired token, bad token.
1209 schema:
1210 type: string
1211 400:
1212 description: Failed - bad code, expired token, bad token.
1213 content:
1214 application/json:
1215 schema:
1216 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1217 /us-verify-link:
1218 parameters:
1219 - name: email
1220 in: query
1221 required: true
1222 schema:
1223 type: string
1224 - name: code
1225 in: query
1226 required: true
1227 schema:
1228 type: string
1229 get:
1230 summary: A magic link to authenticate (instead of manually entering a code).
1231 description: >
1232 This is the result of getting a passcode link and is usually
1233 the result of clicking the link from an email.
1234 This ALWAYS results in a 302 redirect.
1235 N.B. Magic link with 2FA enabled does not work and the SPA will get a redirect to the login error page with tf_required. Must use code option instead.
1236 responses:
1237 302:
1238 description: >
1239 Redirects depending on success/error and whether
1240 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'. Also, if Two-Factor authentication has been enabled, further authentication/redirects might be required.
1241 headers:
1242 Location:
1243 description: |
1244 On spa-success: SECURITY_POST_LOGIN_VIEW?identity={identity}&email={email}
1245
1246 On spa-error-expired: SECURITY_LOGIN_ERROR_VIEW?error={msg}
1247
1248 On spa-error-invalid-token: SECURITY_LOGIN_ERROR_VIEW?error={msg}
1249
1250 On spa-two-factor-required: SECURITY_LOGIN_ERROR_VIEW?tf_required=1
1251
1252 On form-success: SECURITY_POST_LOGIN_VIEW
1253
1254 On form-error-expired: SECURITY_US_SIGNIN_URL
1255
1256 On form-error-invalid-token: SECURITY_US_SIGNIN_URL
1257
1258 On form-success and two-factor: SECURITY_TWO_FACTOR_TOKEN_VALIDATION_URL or SECURITY_TWO_FACTOR_SETUP_URL
1259 schema:
1260 type: string
1261
1262 /tf-setup:
1263 get:
1264 summary: GET Two-factor authentication setup form/information
1265 responses:
1266 200:
1267 description: Setup form
1268 content:
1269 text/html:
1270 schema:
1271 type: string
1272 description: render_template(SECURITY_TWO_FACTOR_SETUP_TEMPLATE)
1273 example: render_template(SECURITY_TWO_FACTOR_SETUP_TEMPLATE)
1274 application/json:
1275 schema:
1276 type: object
1277 properties:
1278 tf_required:
1279 type: string
1280 description: Config setting SECURITY_TWO_FACTOR_REQUIRED.
1281 tf_primary_method:
1282 type: string
1283 description: Current (if any) setup method (deprecated).
1284 tf_method:
1285 type: string
1286 description: Current (if any) setup method.
1287 tf_available_methods:
1288 type: string
1289 description: Config setting SECURITY_TWO_FACTOR_ENABLED_METHODS. If SECURITY_TWO_FACTOR_REQUIRED is false then 'disable' will be part of the set.
1290 tf_phone_number:
1291 type: string
1292 description: Currently configured (if any) phone number.
1293 post:
1294 summary: Two-Factor setup.
1295 description: >
1296 Two-factor setup can be used in three cases:
1297
1298 1) Initial login and application requires 2FA
1299
1300 2) An authenticated user wishing to change their 2FA configuration
1301
1302 3) An authenticated user wishes to enable or disable 2FA (assuming SECURITY_TWO_FACTOR_REQUIRED is False).
1303
1304 Allowed 2FA methods are controlled via the configuration SECURITY_TWO_FACTOR_ENABLED_METHODS.
1305
1306 This endpoint is protected by a 'freshness' check - meaning the caller will be required to have authenticated recently.
1307 In addition, to ensure correctness, the newly setup method must be verified by sending and entering a code prior to it being permanently stored.
1308 requestBody:
1309 required: true
1310 content:
1311 application/json:
1312 schema:
1313 $ref: "#/components/schemas/TfSetup"
1314 application/x-www-form-urlencoded:
1315 schema:
1316 $ref: "#/components/schemas/TfSetup"
1317 responses:
1318 200:
1319 description: >
1320 Two-Factor setup response. Please note that the newly setup method must be validated PRIOR to it being stored permanently.
1321 content:
1322 application/json:
1323 schema:
1324 $ref: "#/components/schemas/TfSetupJsonResponse"
1325 text/html:
1326 schema:
1327 description: Invalid form values or verification code sent successfully and should be entered into the form.
1328 type: string
1329 example: render_template(SECURITY_TWO_FACTOR_SETUP_TEMPLATE) with error values
1330 302:
1331 description: Successfully disabled two-factor.
1332 headers:
1333 Location:
1334 description: |
1335 On form-success: SECURITY_TWO_FACTOR_POST_SETUP_VIEW
1336 schema:
1337 type:
1338 string
1339 400:
1340 description: Errors while validating attributes.
1341 content:
1342 application/json:
1343 schema:
1344 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1345 500:
1346 description: Error when trying to send code.
1347 content:
1348 application/json:
1349 schema:
1350 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1351 /tf-setup/{token}:
1352 parameters:
1353 - name: token
1354 in: path
1355 required: true
1356 schema:
1357 type: string
1358 post:
1359 summary: Validate code sent and store setup method.
1360 requestBody:
1361 required: true
1362 content:
1363 application/json:
1364 schema:
1365 $ref: "#/components/schemas/TfSetupValidateRequest"
1366 application/x-www-form-urlencoded:
1367 schema:
1368 $ref: "#/components/schemas/TfSetupValidateRequest"
1369 responses:
1370 200:
1371 description: Successfully validated and persisted two-factor method.
1372 content:
1373 application/json:
1374 schema:
1375 $ref: "#/components/schemas/TfSetupValidateJsonResponse"
1376 302:
1377 description: Success or Failure.
1378 headers:
1379 Location:
1380 description: |
1381 On form-success: SECURITY_TWO_FACTOR_POST_SETUP_VIEW
1382
1383 On form-error: .tf-setup
1384
1385 Form errors include bad code, expired token, bad token.
1386 schema:
1387 type: string
1388 400:
1389 description: Failed - bad code, expired token, bad token.
1390 content:
1391 application/json:
1392 schema:
1393 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1394 /tf-validate:
1395 get:
1396 summary: GET current two-factor validate code form
1397 responses:
1398 200:
1399 description: Code validation
1400 content:
1401 text/html:
1402 schema:
1403 description: >
1404 If this is a normal, already setup method, then render_template(SECURITY_TWO_FACTOR_VERIFY_CODE_TEMPLATE) is returned.
1405 type: string
1406 post:
1407 summary: Send two-factor code.
1408 parameters:
1409 - $ref: "#/components/parameters/include_auth_token"
1410 requestBody:
1411 required: true
1412 content:
1413 application/json:
1414 schema:
1415 type: object
1416 properties:
1417 code:
1418 description: The code sent via the configured method (e.g. SMS, email, authenticator).
1419 type: string
1420 example: 12345
1421 application/x-www-form-urlencoded:
1422 schema:
1423 type: object
1424 properties:
1425 code:
1426 description: The code sent via the configured method (e.g. SMS, email, authenticator).
1427 type: string
1428 example: 12345
1429 responses:
1430 200:
1431 description: Two-Factor code validation response.
1432 content:
1433 application/json:
1434 schema:
1435 allOf:
1436 - description: >
1437 The code was correct. If this part of user authentication, the caller is now signed in.
1438 If this was part of changing a two-factor method, that was successful.
1439 - $ref: "#/components/schemas/JsonResponseWithToken"
1440 text/html:
1441 schema:
1442 description: >
1443 Unsuccessfully processed code. As above, which form is
1444 rendered depends on the state of the user's two-factor configuration.
1445 type: string
1446 302:
1447 description: User successfully sent code when using form based request.
1448 headers:
1449 Location:
1450 description: >
1451 On form-success for two-factor authentication: SECURITY_POST_LOGIN_VIEW
1452
1453 On form-success for two-factor change method: SECURITY_TWO_FACTOR_SETUP_VIEW
1454 schema:
1455 type: string
1456 400:
1457 description: Errors while validating attributes.
1458 content:
1459 application/json:
1460 schema:
1461 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1462
1463 /tf-rescue:
1464 get:
1465 summary: Help user that has lost authenticator or SMS device.
1466 responses:
1467 200:
1468 description: Return form.
1469 content:
1470 text/html:
1471 schema:
1472 description: >
1473 render_template(SECURITY_TWO_FACTOR_VERIFY_CODE_TEMPLATE).
1474 type: string
1475 post:
1476 summary: Request help.
1477 requestBody:
1478 required: true
1479 content:
1480 application/json:
1481 schema:
1482 type: object
1483 properties:
1484 help_setup:
1485 description: What rescue option is desired.
1486 type: string
1487 enum: [help, email, recovery_code]
1488 example: "recovery_code"
1489 application/x-www-form-urlencoded:
1490 schema:
1491 type: object
1492 properties:
1493 help_setup:
1494 description: What rescue option is desired.
1495 type: string
1496 enum: [help, email, recovery_code]
1497 example: "email"
1498 responses:
1499 200:
1500 description: >
1501 If 'email' was specified and SECURITY_TWO_FACTOR_RESCUE_EMAIL is True,
1502 then an authentication code was sent to the email
1503 on record for the user. If 'help' then an email was sent to administrator address
1504 specified by SECURITY_TWO_FACTOR_RESCUE_MAIL. If 'recovery_code' was specified
1505 and SECURITY_MULTI_FACTOR_RECOVERY_CODES is True, and the user had previously
1506 setup and downloaded a set of recovery codes the user will be redirected to
1507 SECURITY_MULTI_FACTOR_RECOVERY_URL.
1508 content:
1509 application/json:
1510 schema:
1511 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1512 text/html:
1513 schema:
1514 description: Invalid form values or verification code sent successfully and should be entered into the form.
1515 type: string
1516 example: render_template(SECURITY_TWO_FACTOR_VERIFY_CODE_TEMPLATE) with error values
1517 400:
1518 description: Failed to send code
1519 content:
1520 application/json:
1521 schema:
1522 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1523 /tf-select:
1524 get:
1525 summary: Select between previously set up two-factor methods.
1526 description: >
1527 If a user has set up more than one way to provide a second factor of
1528 authentication, this view will ask the user to choose.
1529 responses:
1530 200:
1531 description: Two-factor method select form - SECURITY_TWO_FACTOR_SELECT_TEMPLATE
1532 content:
1533 text/html:
1534 schema:
1535 description: render_template(SECURITY_TWO_FACTOR_SELECT_TEMPLATE)
1536 type: string
1537 example: render_template(SECURITY_TWO_FACTOR_SELECT_TEMPLATE)
1538 application/json:
1539 schema:
1540 allOf:
1541 - $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1542 - type: object
1543 properties:
1544 response:
1545 type: object
1546 properties:
1547 tf_setup_methods:
1548 type: array
1549 items:
1550 type: string
1551 description: A list of methods to choose from
1552 tf_select:
1553 type: boolean
1554 example: True
1555 post:
1556 summary: Select a two-factor method
1557 requestBody:
1558 required: true
1559 content:
1560 application/json:
1561 schema:
1562 type: object
1563 properties:
1564 which:
1565 type: string
1566 description: >
1567 Which two-factor method to use.
1568 example: "sms"
1569 application/x-www-form-urlencoded:
1570 schema:
1571 description: Select Form
1572 type: string
1573 example: render_template(SECURITY_TWO_FACTOR_SELECT_TEMPLATE)
1574 responses:
1575 200:
1576 description: Second factor select response.
1577 content:
1578 application/json:
1579 schema:
1580 $ref: "#/components/schemas/TfSelectJsonResponse"
1581 text/html:
1582 schema:
1583 description: Form validation failure.
1584 type: string
1585 example: render_template(SECURITY_TWO_FACTOR_SELECT_TEMPLATE) with error values
1586 302:
1587 description: User selected which two-factor to use when using form based request.
1588 headers:
1589 Location:
1590 description: Redirect to ``SECURITY_TWO_FACTOR_TOKEN_VALIDATION_URL`` or ``SECURITY_WAN_SIGNIN_URL``.
1591 schema:
1592 type: string
1593 400:
1594 description: Errors while validating attributes.
1595 content:
1596 application/json:
1597 schema:
1598 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1599 /mf-recovery-codes:
1600 summary: Generate and retrieve one-time use recovery codes.
1601 get:
1602 summary: Retrieve one-time use recovery codes.
1603 description: >
1604 If a user has two-factor authentication enabled, they can generate and
1605 use a recovery code if they lose or otherwise can't use their second factor
1606 device.
1607 parameters:
1608 - name: show_codes
1609 in: path
1610 required: false
1611 schema:
1612 type: string
1613 responses:
1614 200:
1615 description: Multi-factor recovery code form
1616 content:
1617 text/html:
1618 schema:
1619 type: string
1620 description: render_template(SECURITY_MULTI_FACTOR_RECOVERY_CODES_TEMPLATE)
1621 example: render_template(SECURITY_MULTI_FACTOR_RECOVERY_CODES_TEMPLATE)
1622 application/json:
1623 schema:
1624 allOf:
1625 - $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1626 - type: object
1627 properties:
1628 response:
1629 type: object
1630 properties:
1631 recovery_codes:
1632 type: array
1633 description: A list of codes
1634 items:
1635 type: string
1636
1637 post:
1638 summary: Generate a new set of one-time recovery codes
1639 responses:
1640 200:
1641 description: New one-time codes generated.
1642 content:
1643 application/json:
1644 schema:
1645 allOf:
1646 - $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1647 - type: object
1648 properties:
1649 response:
1650 type: object
1651 properties:
1652 recovery_codes:
1653 type: array
1654 description: List of new recovery codes
1655 items:
1656 type: string
1657 text/html:
1658 schema:
1659 description: New codes generated - render_template(SECURITY_MULTI_FACTOR_RECOVERY_CODES_TEMPLATE)
1660 type: string
1661 example: render_template(SECURITY_MULTI_FACTOR_RECOVERY_CODES_TEMPLATE)
1662 400:
1663 description: Errors while generating new codes.
1664 content:
1665 application/json:
1666 schema:
1667 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1668
1669 /mf-recovery:
1670 get:
1671 summary: GET recovery code form.
1672 description: >
1673 If a user has two-factor authentication enabled, they can generate and
1674 use a recovery code if they lose or otherwise can't use their second factor
1675 device.
1676 responses:
1677 200:
1678 description: Multi-factor recovery form
1679 content:
1680 text/html:
1681 schema:
1682 type: string
1683 description: render_template(SECURITY_MULTI_FACTOR_RECOVERY_TEMPLATE)
1684 example: render_template(SECURITY_MULTI_FACTOR_RECOVERY_TEMPLATE)
1685 application/json:
1686 schema:
1687 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1688
1689 post:
1690 summary: Use a one-time recovery code to satisfy a two-factor authentication requirement.
1691 requestBody:
1692 required: true
1693 content:
1694 application/json:
1695 schema:
1696 type: object
1697 properties:
1698 code:
1699 type: string
1700 description: One-time recovery code
1701 application/x-www-form-urlencoded:
1702 schema:
1703 description: Use one-time code form
1704 type: string
1705 example: render_template(SECURITY_MULTI_FACTOR_RECOVERY_TEMPLATE)
1706 responses:
1707 200:
1708 description: Successful authentication.
1709 content:
1710 application/json:
1711 schema:
1712 $ref: "#/components/schemas/DefaultJsonResponse"
1713 302:
1714 description: Successful login
1715 headers:
1716 Location:
1717 description: Redirect to ``SECURITY_POST_LOGIN_VIEW``
1718 schema:
1719 type: string
1720 400:
1721 description: Error when validating code.
1722 content:
1723 application/json:
1724 schema:
1725 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1726
1727 /wan-register:
1728 get:
1729 summary: GET Register WebAuthn form
1730 responses:
1731 200:
1732 description: Register WebAuthn form
1733 content:
1734 text/html:
1735 schema:
1736 type: string
1737 description: render_template(SECURITY_WAN_REGISTER_TEMPLATE)
1738 example: render_template(SECURITY_WAN_REGISTER_TEMPLATE)
1739 application/json:
1740 schema:
1741 allOf:
1742 - $ref: '#/components/schemas/BaseJsonResponse'
1743 - type: object
1744 properties:
1745 response:
1746 type: object
1747 properties:
1748 registered_credentials:
1749 type: array
1750 description: List of already registered WebAuthn keys
1751 items:
1752 type: object
1753 properties:
1754 name:
1755 type: string
1756 credential_id:
1757 type: string
1758 transports:
1759 type: string
1760 lastuse:
1761 type: string
1762 usage:
1763 type: string
1764
1765 post:
1766 summary: Register a new WebAuthn key - Step 1
1767 requestBody:
1768 required: true
1769 content:
1770 application/json:
1771 schema:
1772 $ref: "#/components/schemas/WanRegister"
1773 application/x-www-form-urlencoded:
1774 schema:
1775 $ref: "#/components/schemas/WanRegister"
1776 responses:
1777 200:
1778 description: WebAuthn Register Step 1 response
1779 content:
1780 application/json:
1781 schema:
1782 $ref: "#/components/schemas/WanRegisterJsonResponse"
1783 text/html:
1784 schema:
1785 description: Validation failed - render_template(SECURITY_WAN_REGISTER_TEMPLATE)
1786 type: string
1787 example: render_template(SECURITY_WAN_REGISTER_TEMPLATE) with error values
1788 400:
1789 description: Errors while validating attributes.
1790 content:
1791 application/json:
1792 schema:
1793 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1794 /wan-register/{token}:
1795 parameters:
1796 - name: token
1797 in: path
1798 required: true
1799 schema:
1800 type: string
1801 post:
1802 summary: Register a new WebAuthn key - Step 2
1803 requestBody:
1804 required: true
1805 content:
1806 application/json:
1807 schema:
1808 type: object
1809 properties:
1810 credential:
1811 type: string
1812 description: Credential returned from browser
1813 application/x-www-form-urlencoded:
1814 schema:
1815 type: object
1816 properties:
1817 credential:
1818 type: string
1819 description: Credential returned from browser
1820 responses:
1821 200:
1822 description: WebAuthn Register Step 2 response
1823 content:
1824 application/json:
1825 schema:
1826 $ref: "#/components/schemas/DefaultJsonResponse"
1827 302:
1828 description: >
1829 Validation failed - since this form is often auto-submitted
1830 the errors are flashed and user is redirected.
1831 headers:
1832 Location:
1833 description: Redirect to ``SECURITY_WAN_REGISTER_URL``
1834 schema:
1835 type: string
1836 400:
1837 description: Errors while validating attributes.
1838 content:
1839 application/json:
1840 schema:
1841 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1842 /wan-signin:
1843 get:
1844 summary: GET WebAuthn sign in form
1845 responses:
1846 200:
1847 description: Sign in with WebAuthn form
1848 content:
1849 text/html:
1850 schema:
1851 type: string
1852 description: render_template(SECURITY_WAN_SIGNIN_TEMPLATE)
1853 example: render_template(SECURITY_WAN_SIGNIN_TEMPLATE)
1854 application/json:
1855 schema:
1856 allOf:
1857 - $ref: '#/components/schemas/BaseJsonResponse'
1858 - type: object
1859 properties:
1860 response:
1861 type: object
1862 properties:
1863 registered_credentials:
1864 type: array
1865 description: List of already registered WebAuthn keys
1866 items:
1867 type: object
1868 properties:
1869 name:
1870 type: string
1871 credential_id:
1872 type: string
1873 transports:
1874 type: string
1875 lastuse:
1876 type: string
1877 usage:
1878 type: string
1879
1880 post:
1881 summary: Sign in using a WebAuthn key - Step 1
1882 requestBody:
1883 required: true
1884 content:
1885 application/json:
1886 schema:
1887 $ref: "#/components/schemas/WanSignin"
1888 application/x-www-form-urlencoded:
1889 schema:
1890 $ref: "#/components/schemas/WanSignin"
1891 responses:
1892 200:
1893 description: WebAuthn Sign in Step 1 response
1894 content:
1895 application/json:
1896 schema:
1897 $ref: "#/components/schemas/WanSigninJsonResponse"
1898 text/html:
1899 schema:
1900 description: >
1901 Next step OR Validation failed.
1902 If valid form then "wan_state" and "credential_options" will be set.
1903 If not valid, form will have error values filled in.
1904 type: string
1905 example: render_template(SECURITY_WAN_SIGNIN_TEMPLATE)
1906 400:
1907 description: Errors while validating attributes.
1908 content:
1909 application/json:
1910 schema:
1911 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1912 /wan-signin/{token}:
1913 parameters:
1914 - name: token
1915 in: path
1916 required: true
1917 schema:
1918 type: string
1919 post:
1920 summary: Sign in using a WebAuthn key - Step 2
1921 parameters:
1922 - $ref: "#/components/parameters/include_auth_token"
1923 requestBody:
1924 required: true
1925 content:
1926 application/json:
1927 schema:
1928 $ref: "#/components/schemas/WanSignin2"
1929 application/x-www-form-urlencoded:
1930 schema:
1931 $ref: "#/components/schemas/WanSignin2"
1932 responses:
1933 200:
1934 description: WebAuthn Sign in Step 2 response
1935 content:
1936 application/json:
1937 schema:
1938 $ref: "#/components/schemas/JsonResponseWithToken"
1939 302:
1940 description: >
1941 Validation failed - since this form is often auto-submitted
1942 the errors are flashed and user is redirected.
1943 headers:
1944 Location:
1945 description: Redirect to ``SECURITY_WAN_SIGNIN_URL``
1946 schema:
1947 type: string
1948 400:
1949 description: Errors while validating attributes.
1950 content:
1951 application/json:
1952 schema:
1953 $ref: "#/components/schemas/DefaultJsonErrorResponse"
1954 /wan-delete:
1955 get:
1956 summary: GET Delete WebAuthn key - this method isn't very useful.
1957 responses:
1958 200:
1959 description: Delete an existing WebAuthn Key
1960 content:
1961 application/json:
1962 schema:
1963 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1964 302:
1965 description: >
1966 This form is associated with the register endpoint and so redirects there.
1967 headers:
1968 Location:
1969 description: Redirect to ``SECURITY_WAN_REGISTER_URL``
1970 schema:
1971 type: string
1972 post:
1973 summary: Delete an existing WebAuthn key
1974 requestBody:
1975 required: true
1976 content:
1977 application/json:
1978 schema:
1979 $ref: "#/components/schemas/WanDelete"
1980 application/x-www-form-urlencoded:
1981 schema:
1982 $ref: "#/components/schemas/WanDelete"
1983 responses:
1984 200:
1985 description: Delete response
1986 content:
1987 application/json:
1988 schema:
1989 $ref: "#/components/schemas/DefaultJsonResponseNoUser"
1990 302:
1991 description: >
1992 Validation failed - this form is part of the registration form
1993 so any errors or success redirects there.
1994 headers:
1995 Location:
1996 description: Redirect to ``SECURITY_WAN_REGISTER_URL``
1997 schema:
1998 type: string
1999 400:
2000 description: Errors while validating attributes.
2001 content:
2002 application/json:
2003 schema:
2004 $ref: "#/components/schemas/DefaultJsonErrorResponse"
2005 /wan-verify:
2006 get:
2007 summary: GET Reauthenticate using WebAuthn form
2008 description: >
2009 If an endpoint is protected with @auth_required() with a freshness declaration
2010 this endpoint can be used to reauthenticate with a previously registered WebAuthn Key.
2011 responses:
2012 200:
2013 description: Verify/reauthenticate form
2014 content:
2015 text/html:
2016 schema:
2017 type: string
2018 description: render_template(SECURITY_WAN_VERIFY_TEMPLATE)
2019 example: render_template(SECURITY_WAN_VERIFY_TEMPLATE)
2020 application/json:
2021 schema:
2022 $ref: "#/components/schemas/DefaultJsonResponse"
2023 post:
2024 summary: Reauthenticate using a WebAuthn Key.
2025 responses:
2026 200:
2027 description: Verify/Reauthenticate response.
2028 content:
2029 application/json:
2030 schema:
2031 $ref: "#/components/schemas/WanVerifyJsonResponse"
2032 text/html:
2033 schema:
2034 description: >
2035 Next step OR Validation failed.
2036 If valid form then "wan_state" and "credential_options" will be set.
2037 If not valid, form will have error values filled in.
2038 type: string
2039 example: render_template(SECURITY_WAN_VERIFY_TEMPLATE)
2040 400:
2041 description: Errors while validating attributes.
2042 content:
2043 application/json:
2044 schema:
2045 $ref: "#/components/schemas/DefaultJsonErrorResponse"
2046 /wan-verify/{token}:
2047 parameters:
2048 - name: token
2049 in: path
2050 required: true
2051 schema:
2052 type: string
2053 post:
2054 summary: Reauthenticate using a WebAuthn Key - Part 2.
2055 parameters:
2056 - $ref: "#/components/parameters/include_auth_token"
2057 requestBody:
2058 required: true
2059 content:
2060 application/json:
2061 schema:
2062 $ref: "#/components/schemas/WanSignin2"
2063 application/x-www-form-urlencoded:
2064 schema:
2065 $ref: "#/components/schemas/WanSignin2"
2066 responses:
2067 200:
2068 description: Verify/Reauthenticate response.
2069 content:
2070 application/json:
2071 schema:
2072 allOf:
2073 - description: >
2074 The user successfully reauthenticated.
2075 - $ref: "#/components/schemas/JsonResponseWithToken"
2076 302:
2077 description: User successfully reauthenticated or error in validation when using form based request.
2078 headers:
2079 Location:
2080 description: >
2081 Redirect to ``next`` or ``SECURITY_POST_VERIFY_VIEW`` (on success)
2082 or ``SECURITY_WAN_VERIFY_URL`` on validation failure.
2083 schema:
2084 type: string
2085 400:
2086 description: Errors while validating attributes.
2087 content:
2088 application/json:
2089 schema:
2090 $ref: "#/components/schemas/DefaultJsonErrorResponse"
2091 /login/oauthstart/{name}:
2092 parameters:
2093 - name: name
2094 in: path
2095 required: true
2096 schema:
2097 type: string
2098 description: provider name as registered with OAuth (e.g. 'github')
2099 post:
2100 summary: Start a Social Login (OAuth) authentication exchange.
2101 responses:
2102 302:
2103 description: >
2104 Redirect to OAuth provider. The value of the `next` query argument will be
2105 stored in the session and retrieved when the OAuth provider
2106 performs a GET on the redirect URL. If the caller is already
2107 authenticated redirect will be to ``SECURITY_POST_LOGIN_VIEW``
2108 400:
2109 description: Caller is already authenticated
2110 content:
2111 application/json:
2112 schema:
2113 $ref: "#/components/schemas/DefaultJsonErrorResponse"
2114 /login/oauthresponse/{name}:
2115 parameters:
2116 - name: name
2117 in: path
2118 required: true
2119 schema:
2120 type: string
2121 description: provider name as registered with OAuth (e.g. 'github')
2122 get:
2123 summary: Response from OAuth provider.
2124 responses:
2125 302:
2126 description: >
2127 Caller will be redirected based on whether successful or not and whether
2128 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'.
2129 headers:
2130 Location:
2131 description: |
2132 On spa-success: SECURITY_POST_OAUTH_LOGIN_VIEW?identity={identity}&email={email}
2133
2134 On spa-oauth-error: SECURITY_LOGIN_ERROR_VIEW?error={msg}
2135
2136 On spa-unknown-user: SECURITY_LOGIN_ERROR_VIEW?error={msg}
2137
2138 On form-success: `next` or SECURITY_POST_LOGIN_VIEW
2139 schema:
2140 type: string
2141 /login/oauth-verify-start/{name}:
2142 parameters:
2143 - name: name
2144 in: path
2145 required: true
2146 schema:
2147 type: string
2148 description: provider name as registered with OAuth (e.g. 'github')
2149 post:
2150 summary: Start a Social Login (OAuth) reauthentication exchange.
2151 responses:
2152 302:
2153 description: >
2154 Redirect to OAuth provider. The value of the `next` query argument will be
2155 stored in the session and retrieved when the OAuth provider
2156 performs a GET on the redirect URL.
2157 /login/oauth-verify-response/{name}:
2158 parameters:
2159 - name: name
2160 in: path
2161 required: true
2162 schema:
2163 type: string
2164 description: provider name as registered with OAuth (e.g. 'github')
2165 get:
2166 summary: Response from OAuth provider.
2167 responses:
2168 302:
2169 description: >
2170 Caller will be redirected based on whether successful or not and whether
2171 __SECURITY_REDIRECT_BEHAVIOR__ == 'spa'.
2172 headers:
2173 Location:
2174 description: |
2175 On spa-success: SECURITY_POST_OAUTH_VERIFY_VIEW?identity={identity}&email={email}
2176
2177 On spa-oauth-error: SECURITY_VERIFY_ERROR_VIEW?error={msg}
2178
2179 On spa-unknown-user: SECURITY_VERIFY_ERROR_VIEW?error={msg}
2180
2181 On form-success: `next` or SECURITY_POST_VERIFY_VIEW
2182 schema:
2183 type: string
2184
2185
2186 components:
2187 schemas:
2188 Login:
2189 type: object
2190 required: [email, password]
2191 properties:
2192 email:
2193 type: string
2194 description: user email
2195 password:
2196 type: string
2197 description: Password
2198 remember:
2199 type: boolean
2200 description: >
2201 If true, will remember userid as part of cookie. There is a configuration variable DEFAULT_REMEMBER_ME that can be set. This field will override that.
2202 LoginJsonResponse:
2203 type: object
2204 allOf:
2205 - $ref: '#/components/schemas/JsonResponseWithToken'
2206 - type: object
2207 properties:
2208 response:
2209 type: object
2210 properties:
2211 tf_required:
2212 type: boolean
2213 description: True if two-factor authentication is required for caller.
2214 tf_state:
2215 type: string
2216 description: if "setup_from_login" then the caller must go through two-factor setup endpoint. If "ready" then a code has been sent and should be supplied to SECURITY_TWO_FACTOR_TOKEN_VALIDATION_URL.
2217 tf_method:
2218 type: string
2219 description: Which method was used to send code.
2220 example: "webauthn"
2221 tf_select:
2222 type: boolean
2223 description: >
2224 If user has setup multiple forms of two-factor authentication, this will be True
2225 and the application should prompt the user for which method they want to use.
2226 tf_setup_methods:
2227 type: array
2228 items:
2229 type: string
2230 description: If user has setup multiple forms of two-factor authentication, they are listed
2231
2232 BaseJsonResponse:
2233 type: object
2234 required: [ meta, response ]
2235 properties:
2236 meta:
2237 type: object
2238 required: [ code ]
2239 properties:
2240 code:
2241 type: integer
2242 example: 200
2243 description: Http status code
2244 DefaultJsonResponse:
2245 allOf:
2246 - $ref: '#/components/schemas/BaseJsonResponse'
2247 - type: object
2248 properties:
2249 response:
2250 type: object
2251 properties:
2252 user:
2253 type: object
2254 description: >
2255 By default an empty dictionary is returned. However by overriding _User::get_security_payload()_ any attributes of the User model can be returned.
2256 csrf_token:
2257 type: string
2258 description: Session CSRF token
2259 DefaultJsonResponseNoUser:
2260 allOf:
2261 - $ref: '#/components/schemas/BaseJsonResponse'
2262 - type: object
2263 properties:
2264 response:
2265 type: object
2266 properties:
2267 csrf_token:
2268 type: string
2269 description: Session CSRF token
2270 JsonResponseWithToken:
2271 allOf:
2272 - $ref: '#/components/schemas/BaseJsonResponse'
2273 - type: object
2274 properties:
2275 response:
2276 type: object
2277 properties:
2278 user:
2279 type: object
2280 description: >
2281 By default an empty dictionary is returned. However by overriding _User::get_security_payload()_ any attributes of the User model can be returned.
2282 properties:
2283 authentication_token:
2284 type: string
2285 description: >
2286 Token to be used in future token-based API calls.
2287 Note this only returned from those APIs that accept a
2288 'include_auth_token' query param.
2289 csrf_token:
2290 type: string
2291 description: Session CSRF token
2292 DefaultJsonErrorResponse:
2293 type: object
2294 required: [ meta, response ]
2295 properties:
2296 meta:
2297 type: object
2298 required: [ code ]
2299 properties:
2300 code:
2301 type: integer
2302 example: 400
2303 description: Http status code
2304 response:
2305 type: object
2306 required: [ errors ]
2307 description: >
2308 For form validation errors, the 'field_errors' key will be set with a list of errors per
2309 invalid form input field (i.e. a dict of 'field-name': list of error strings).
2310 The 'errors' key will be a simple list of both form and non-form related
2311 errors (all form errors will also be included here).
2312 properties:
2313 field_errors:
2314 type: object
2315 description: >
2316 Errors per input/form field
2317 additionalProperties:
2318 type: array
2319 items:
2320 type: string
2321 example: field validation error.
2322 description: Error message (localized)
2323 errors:
2324 type: array
2325 items:
2326 type: string
2327 example: "Unauthenticated"
2328 description: Error message (localized)
2329 Verify:
2330 type: object
2331 required: [ password ]
2332 properties:
2333 password:
2334 type: string
2335 description: Password
2336 Register:
2337 type: object
2338 required: [email, password]
2339 properties:
2340 email:
2341 type: string
2342 description: >
2343 user identifier. This is by default an email address, but can be any (unique)
2344 field that is part of the User model and is defined in the __SECURITY_USER_IDENTITY_ATTRIBUTES__ configuration variable. It will also match against numeric User model fields.
2345 password:
2346 type: string
2347 description: Password
2348 RegisterForm:
2349 type: object
2350 required: [email, password]
2351 properties:
2352 email:
2353 type: string
2354 description: >
2355 user identifier. This is by default an email address, but can be any (unique)
2356 field that is part of the User model and is defined in the __SECURITY_USER_IDENTITY_ATTRIBUTES__ configuration variable. It will also match against numeric User model fields.
2357 password:
2358 type: string
2359 description: Password
2360 password_confirm:
2361 type: string
2362 description: >
2363 If present, must re-type in password. This will not be present if the __SECURITY_PASSWORD_CONFIRM_REQUIRED__ configuration is False.
2364 next:
2365 type: string
2366 description: >
2367 Redirect URL. Overrides __SECURITY_POST_REGISTER_VIEW__.
2368 ResetPassword:
2369 type: object
2370 required: [password, password_confirm]
2371 properties:
2372 password:
2373 type: string
2374 description: Password
2375 password_confirm:
2376 type: string
2377 description: Password - again
2378 ChangePassword:
2379 type: object
2380 required: [password, new_password, new_password_confirm]
2381 properties:
2382 password:
2383 type: string
2384 description: Password
2385 new_password:
2386 type: string
2387 description: New password
2388 new_password_confirm:
2389 type: string
2390 description: New password - again
2391 ChangeEmail:
2392 type: object
2393 required: [email]
2394 properties:
2395 email:
2396 type: string
2397 description: New email requested
2398 ChangeUsername:
2399 type: object
2400 required: [username]
2401 properties:
2402 username:
2403 type: string
2404 description: New username
2405
2406 EmailLink:
2407 type: object
2408 required: [email]
2409 properties:
2410 email:
2411 type: string
2412 description: >
2413 Email address to send link email to.
2414 RecoverUsername:
2415 type: object
2416 required: [email]
2417 properties:
2418 email:
2419 type: string
2420 description: >
2421 Email address associated with the account.
2422 UsSignin:
2423 type: object
2424 required: [identity, passcode]
2425 properties:
2426 identity:
2427 type: string
2428 description: Configured by SECURITY_USER_IDENTITY_ATTRIBUTES
2429 example: [email protected], +16505551212
2430 passcode:
2431 type: string
2432 description: password or code
2433 remember:
2434 type: boolean
2435 UsSigninSendCode:
2436 type: object
2437 required: [identity, chosen_method]
2438 properties:
2439 identity:
2440 type: string
2441 description: Configured by SECURITY_USER_IDENTITY_ATTRIBUTES
2442 example: [email protected], +16505551212
2443 chosen_method:
2444 type: string
2445 description: which method should be used to send the code, as configured with SECURITY_US_ENABLED_METHODS
2446 UsSigninVerify:
2447 type: object
2448 required: [passcode]
2449 properties:
2450 passcode:
2451 type: string
2452 description: password or code
2453 UsSigninVerifySendCode:
2454 type: object
2455 required: [chosen_method]
2456 properties:
2457 chosen_method:
2458 type: string
2459 description: which method should be used to send the code, as configured with SECURITY_US_ENABLED_METHODS
2460 UsSetup:
2461 type: object
2462 properties:
2463 chosen_method:
2464 type: string
2465 description: which method should be used to send the code, as configured with SECURITY_US_ENABLED_METHODS
2466 delete_method:
2467 type: string
2468 description: which previously set up method should be deleted.
2469 phone:
2470 type: string
2471 description: phone number (this will be normalized). Required if chosen_method == "sms".
2472 UsSetupJsonResponse:
2473 allOf:
2474 - $ref: '#/components/schemas/BaseJsonResponse'
2475 - type: object
2476 properties:
2477 response:
2478 type: object
2479 description: Response when setting up a new method. When deleting, nothing is returned.
2480 properties:
2481 chosen_method:
2482 type: string
2483 description: The chosen_method as passed into API.
2484 phone:
2485 type: string
2486 description: The canonicalized phone number if setting up SMS
2487 authr_key:
2488 type: string
2489 description: Pretty TOTP key for setting up authenticator manually (if chosen_method == 'authenticator')
2490 authr_b32key:
2491 type: string
2492 description: Base32 TOTP key for setting up authenticator (useful to create a uri) (if chosen_method == 'authenticator')
2493 authr_uri:
2494 type: string
2495 description: A 'otpauth://' style URI suitable to creating a QRCode (if chosen_method == 'authenticator')
2496 authr_issuer:
2497 type: string
2498 description: Issuer as configured with TOTP_ISSUER (same as used in QRcode) (if chosen_method == 'authenticator')
2499 authr_username:
2500 type: string
2501 description: Username (same as used in QRcode) (if chosen_method == 'authenticator')
2502 state:
2503 type: string
2504 description: Opaque blob that must be pass to /us-setup/<state>. This is a signed, timed token.
2505 UsSetupValidateRequest:
2506 type: object
2507 required: [passcode]
2508 properties:
2509 passcode:
2510 type: string
2511 description: Code/Passcode as received from method being setup.
2512 UsSetupValidateJsonResponse:
2513 allOf:
2514 - $ref: '#/components/schemas/BaseJsonResponse'
2515 - type: object
2516 properties:
2517 response:
2518 type: object
2519 properties:
2520 chosen_method:
2521 type: string
2522 description: The chosen_method as passed into API.
2523 phone:
2524 type: string
2525 description: Phone number if set.
2526 TfSetup:
2527 type: object
2528 required: [setup]
2529 properties:
2530 setup:
2531 type: string
2532 description: >
2533 Which method should be used to send the code, as configured with SECURITY_TWO_FACTOR_ENABLED_METHODS.
2534 If SECURITY_TWO_FACTOR_REQUIRED is False, the additional method 'disable' is available.
2535 example: sms
2536 phone:
2537 type: string
2538 description: phone number (this will be validated for format). Required if setup == "sms".
2539 example: 650-555-1212
2540 TfSetupJsonResponse:
2541 allOf:
2542 - $ref: '#/components/schemas/BaseJsonResponse'
2543 - type: object
2544 properties:
2545 response:
2546 type: object
2547 properties:
2548 tf_state:
2549 type: string
2550 description: >
2551 Current state of Two-Factor configuration. Not present when disabling 2FA. This will be set to 'validating_profile'
2552 indicating the caller needs to call '/tf-validate' with the correct code.
2553 N.B. as of 5.5.0 this is only used for setting up as part of initial login when 2FA is required.
2554 See tf_state_token below for use when an authenticated user wants to change their 2FA method.
2555 example: validating_profile
2556 tf_state_token:
2557 type: string
2558 description: >
2559 Timed and signed token containing necessary state to complete the setup. To validate the method POST
2560 the code to '/tf-setup/<tf_state_token>'.
2561 tf_primary_method:
2562 type: string
2563 description: Current method being configured (deprecated).
2564 example: sms
2565 tf_method:
2566 type: string
2567 description: Current method being configured.
2568 example: sms
2569 tf_authr_key:
2570 type: string
2571 description: Pretty TOTP key for setting up authenticator manually (if tf_primary_method == 'authenticator')
2572 tf_authr_b32key:
2573 type: string
2574 description: Base32 TOTP key for setting up authenticator (useful to create a uri) (if chosen_method == 'authenticator')
2575 tf_authr_uri:
2576 type: string
2577 description: A 'otpauth://' style URI suitable to creating a QRCode (if chosen_method == 'authenticator')
2578 tf_authr_issuer:
2579 type: string
2580 description: Issuer as configured with TOTP_ISSUER (same as used in QRcode) (if tf_primary_method == 'authenticator')
2581 tf_authr_username:
2582 type: string
2583 description: Username (same as used in QRcode) (if tf_primary_method == 'authenticator')
2584 TfSelectJsonResponse:
2585 allOf:
2586 - $ref: '#/components/schemas/BaseJsonResponse'
2587 - oneOf:
2588 - type: object
2589 description: >
2590 The user requires two-factor authorization and has chosen which one to use.
2591 properties:
2592 response:
2593 type: object
2594 properties:
2595 tf_required:
2596 type: boolean
2597 description: Will be True since a second factor is required.
2598 tf_state:
2599 type: string
2600 description: if "setup_from_login" then the caller must go through two-factor setup endpoint. If "ready" then a code has been sent and should be supplied to SECURITY_TWO_FACTOR_TOKEN_VALIDATION_URL.
2601 tf_method:
2602 type: string
2603 description: Which method was used to send code/link.
2604 example: "sms"
2605 - type: object
2606 description: >
2607 The user requires two-factor authorization and has chosen to use `webauthn`.
2608 properties:
2609 response:
2610 type: object
2611 properties:
2612 tf_required:
2613 type: boolean
2614 description: Will be True since a second factor is required.
2615 tf_state:
2616 type: string
2617 description: This will be set to `ready`.
2618 tf_method:
2619 type: string
2620 description: This will be set to `webauthn`.
2621 tf_signin_url:
2622 type: string
2623 description: The value of SECURITY_WAN_SIGNIN_URL
2624 TfSetupValidateRequest:
2625 type: object
2626 required: [code]
2627 properties:
2628 code:
2629 type: string
2630 description: Code as received from method being setup.
2631 TfSetupValidateJsonResponse:
2632 allOf:
2633 - $ref: '#/components/schemas/BaseJsonResponse'
2634 - type: object
2635 properties:
2636 response:
2637 type: object
2638 properties:
2639 tf_method:
2640 type: string
2641 description: The method as passed into API.
2642 tf_primary_method:
2643 type: string
2644 description: The method as passed into API.
2645 tf_phone:
2646 type: string
2647 description: Phone number if set.
2648 WanRegister:
2649 type: object
2650 required: [ name, usage ]
2651 properties:
2652 name:
2653 type: string
2654 example: Wankey1
2655 usage:
2656 type: string
2657 enum: [ first, secondary ]
2658 WanRegisterJsonResponse:
2659 allOf:
2660 - $ref: '#/components/schemas/BaseJsonResponse'
2661 - type: object
2662 properties:
2663 response:
2664 type: object
2665 properties:
2666 credential_options:
2667 type: string
2668 wan_state:
2669 type: string
2670 WanSignin:
2671 type: object
2672 properties:
2673 identity:
2674 type: string
2675 example: [email protected]
2676 remember:
2677 type: boolean
2678 description: >
2679 If true, will remember userid as part of cookie. There is a configuration variable DEFAULT_REMEMBER_ME that can be set. This field will override that.
2680 WanSigninJsonResponse:
2681 allOf:
2682 - $ref: '#/components/schemas/BaseJsonResponse'
2683 - type: object
2684 properties:
2685 response:
2686 type: object
2687 properties:
2688 credential_options:
2689 type: string
2690 wan_state:
2691 type: string
2692 is_secondary:
2693 type: boolean
2694 description: Is this sign in part of a secondary authentication.
2695 remember:
2696 type: boolean
2697 description: This is simply the same value as was passed in the body.
2698 WanSignin2:
2699 type: object
2700 required: [ credential ]
2701 properties:
2702 credential:
2703 type: string
2704 description: Credential returned from browser
2705 remember:
2706 type: boolean
2707 WanDelete:
2708 type: object
2709 required: [ name ]
2710 properties:
2711 name:
2712 type: string
2713 description: Name of WebAuthn key to delete.
2714 WanVerifyJsonResponse:
2715 allOf:
2716 - $ref: '#/components/schemas/BaseJsonResponse'
2717 - type: object
2718 properties:
2719 response:
2720 type: object
2721 properties:
2722 credential_options:
2723 type: string
2724 wan_state:
2725 type: string
2726
2727 headers:
2728 X-CSRF-Token:
2729 description: CSRF token
2730 schema:
2731 type: string
2732 parameters:
2733 include_auth_token:
2734 name: include_auth_token
2735 description: If set/sent, will return an Authentication Token for user
2736 in: query
2737 schema:
2738 type: string