You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basic auth didn't reject deactivated users.
Basic Auth didn't return WWW-Authenticate when request was JSON.
Introduced a new config variable SECURITY_API_ENABLED_METHODS which configures which of (basic, session, token) will be used
to authenticate Flask-Security's endpoints that require it.
change the @auth_required decorator to take a callable which can reference context variables (such as config).
Change all endpoints that require authentication to use new config variable.
Fixes: #368
Fixes: #369
Copy file name to clipboardExpand all lines: docs/patterns.rst
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,16 @@ own code. Then use Flask's ``errorhandler`` to catch that exception and create t
57
57
raise MyForbiddenException(msg='You can only update docs you own')
58
58
59
59
60
+
A note about Basic Auth
61
+
+++++++++++++++++++++++
62
+
Basic Auth is supported in Flask-Security, using the @http_auth_required() decorator. If a request for an endpoint
63
+
protected with @http_auth_required is received, and the request doesn't contain the appropriate HTTP Headers, a 401 is returned
64
+
along with the required WWW-Authenticate header. In this case there won't be a usable session cookie returned so all future requests
65
+
will also require credentials to be sent. Effectively the caller is temporarily 'logged in' at the beginning of each request and 'logged out' again
66
+
at the end of the request. Most (all?) browsers intercept this response and pop up a login dialog box and remember, for the site, the entered credentials.
67
+
This effectively bypasses any of the normal Flask-Security login forms. By default, the Flask-Security endpoints that require the caller be
68
+
authenticated do NOT support ``basic`` - however the :py:data:`SECURITY_API_ENABLED_METHODS` can be used to override this.
69
+
60
70
Freshness
61
71
++++++++++
62
72
A common pattern for browser-based sites is to use sessions to manage identity. This is usually
0 commit comments