1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
API
===
The external (json/form) API is described `here`_
.. _here: _static/openapi_view.html
Core
----
.. autoclass:: flask_security.Security
:members:
.. data:: flask_security.current_user
A proxy for the current user.
.. function:: flask_security.Security.unauthorized_handler
If an endpoint fails authentication or authorization from one of the decorators
described below
(except ``login_required``), a method annotated with this decorator will be called.
For ``login_required`` (which is implemented in Flask-Login) use
**flask_security.login_manager.unauthorized_handler**
.. deprecated:: 3.3.0
Protecting Views
----------------
.. autofunction:: flask_security.anonymous_user_required
.. autofunction:: flask_security.http_auth_required
.. autofunction:: flask_security.auth_token_required
.. autofunction:: flask_security.auth_required
.. autofunction:: flask_security.login_required
.. autofunction:: flask_security.roles_required
.. autofunction:: flask_security.roles_accepted
.. autofunction:: flask_security.permissions_required
.. autofunction:: flask_security.permissions_accepted
.. autofunction:: flask_security.unauth_csrf
.. autofunction:: flask_security.handle_csrf
User Object Helpers
-------------------
.. autoclass:: flask_security.UserMixin
:members:
.. autoclass:: flask_security.RoleMixin
:members:
.. autoclass:: flask_security.AnonymousUser
:members:
Datastores
----------
.. autoclass:: flask_security.UserDatastore
:members:
.. autoclass:: flask_security.SQLAlchemyUserDatastore
:members:
:inherited-members:
.. autoclass:: flask_security.SQLAlchemySessionUserDatastore
:members:
:inherited-members:
.. autoclass:: flask_security.MongoEngineUserDatastore
:members:
:inherited-members:
.. autoclass:: flask_security.PeeweeUserDatastore
:members:
:inherited-members:
.. autoclass:: flask_security.PonyUserDatastore
:members:
:inherited-members:
Utils
-----
.. autofunction:: flask_security.login_user
.. autofunction:: flask_security.logout_user
.. autofunction:: flask_security.check_and_update_authn_fresh
.. autofunction:: flask_security.get_hmac
.. autofunction:: flask_security.get_request_attr
.. autofunction:: flask_security.verify_password
.. autofunction:: flask_security.verify_and_update_password
.. autofunction:: flask_security.hash_password
.. autofunction:: flask_security.uia_phone_mapper
.. autofunction:: flask_security.uia_email_mapper
.. autofunction:: flask_security.url_for_security
.. autofunction:: flask_security.send_mail
.. autofunction:: flask_security.get_token_status
.. autofunction:: flask_security.check_and_get_token_status
.. autofunction:: flask_security.get_url
.. autofunction:: flask_security.password_length_validator
.. autofunction:: flask_security.password_complexity_validator
.. autofunction:: flask_security.password_breached_validator
.. autofunction:: flask_security.pwned
.. autofunction:: flask_security.transform_url
.. autofunction:: flask_security.unique_identity_attribute
.. autofunction:: flask_security.us_send_security_token
.. autofunction:: flask_security.tf_send_security_token
.. autoclass:: flask_security.FsJsonEncoder
.. autoclass:: flask_security.Totp
:members: get_last_counter, set_last_counter, generate_qrcode
.. autoclass:: flask_security.PhoneUtil
:members:
:special-members: __init__
.. autoclass:: flask_security.MailUtil
:members:
:special-members: __init__
.. autoclass:: flask_security.PasswordUtil
:members:
:special-members: __init__
.. autoclass:: flask_security.SmsSenderBaseClass
:members: send_sms
.. autoclass:: flask_security.SmsSenderFactory
:members: createSender
.. _signals_topic:
Signals
-------
See the `Flask documentation on signals`_ for information on how to use these
signals in your code.
.. tip::
Remember to add ``**extra_args`` to your signature so that if we add
additional parameters in the future your code doesn't break.
See the documentation for the signals provided by the Flask-Login and
Flask-Principal extensions. In addition to those signals, Flask-Security
sends the following signals.
.. data:: user_authenticated
Sent when a user successfully authenticates. In addition to the app (which is the
sender), it is passed `user`, and `authn_via` arguments. The `authn_via` argument
specifies how the user authenticated - it will be a list with possible values
of ``password``, ``sms``, ``authenticator``, ``email``, ``confirm``, ``reset``,
``register``.
.. versionadded:: 3.4.0
.. data:: user_registered
Sent when a user registers on the site. In addition to the app (which is the
sender), it is passed `user`, `confirm_token` and `form_data` arguments.
`form_data` is a dictionary representation of registration form's content
received with registration request.
.. data:: user_confirmed
Sent when a user is confirmed. In addition to the app (which is the
sender), it is passed a `user` argument.
.. data:: confirm_instructions_sent
Sent when a user requests confirmation instructions. In addition to the app
(which is the sender), it is passed a `user` argument.
.. data:: login_instructions_sent
Sent when passwordless login is used and user logs in. In addition to the app
(which is the sender), it is passed `user` and `login_token` arguments.
.. data:: password_reset
Sent when a user completes a password reset. In addition to the app (which is
the sender), it is passed a `user` argument.
.. data:: password_changed
Sent when a user completes a password change. In addition to the app (which is
the sender), it is passed a `user` argument.
.. data:: reset_password_instructions_sent
Sent when a user requests a password reset. In addition to the app (which is
the sender), it is passed `user` and `token` arguments.
.. data:: tf_code_confirmed
Sent when a user performs two-factor authentication login on the site. In
addition to the app (which is the sender), it is passed `user`
and `method` arguments.
.. versionadded:: 3.3.0
.. data:: tf_profile_changed
Sent when two-factor is used and user logs in. In addition to the app
(which is the sender), it is passed `user` and `method` arguments.
.. versionadded:: 3.3.0
.. data:: tf_disabled
Sent when two-factor is disabled. In addition to the app
(which is the sender), it is passed `user` argument.
.. versionadded:: 3.3.0
.. data:: tf_security_token_sent
Sent when a two factor security/access code is sent. In addition to the app
(which is the sender), it is passed `user`, `method`, and `token` arguments.
.. versionadded:: 3.3.0
.. data:: us_security_token_sent
Sent when a unified sign in access code is sent. In addition to the app
(which is the sender), it is passed `user`, `method`, `token`,
`phone_number`, and `send_magic_link` arguments.
.. versionadded:: 3.4.0
.. data:: us_profile_changed
Sent when user completes changing their unified sign in profile. In addition to the app
(which is the sender), it is passed `user` and `method` arguments.
.. versionadded:: 3.4.0
.. _Flask documentation on signals: https://flask.palletsprojects.com/en/1.1.x/signals/
|