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