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
{{ message }}
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
Flask-WTF has a great function, CsrfProtect that will raise an exception whenever a non-GET request is made if the route doesn't check for a form validation. In fact, without this, functions like remove_connections are currently vulnerable to a csrf attack.
Implementation is fairly simple. In the view functions we just:
@mattupstate wanted to get your opinion on implementation before I work too far on this. @talos will likely also be working with me on it as well, so if any input from either of you would be great.
I was thinking for the first part, we'd want to wrap it in a config check, app.config['CSRF_ENABLED'] that is set by calling the CsrfProtect function. It might be useful to also set an override, app.config['SOCIAL_CSRF_ENABLED'], but this might be overkill and over complicated.
Also, the template stuff is obviously a change to Flask-Social-Example. I think it makes sense to turn it on for the example, both since it's a good practice to use something like CsrfProtect, and so that we can have the example reflecting that use case.
The text was updated successfully, but these errors were encountered:
@eriktaubeneck I'm not sure its necessary. While the forms do require a POST to get the OAuth flow started, we're not manipulating any data on the server in the context of that request.
remove_all_connections and remove_connection would both delete data in your datastore if attacked. Moreover, if you want to use the CsrfProtect function that Flask-WTF provides, it breaks all of the social routes.
Hi guys - any updates on this? I'm trying to use Flask-Social on my site and I'm having issues because my other forms are csrf protected but Flask-Social's forms aren't.
Flask-WTF has a great function,
CsrfProtect
that will raise an exception whenever a non-GET request is made if the route doesn't check for a form validation. In fact, without this, functions likeremove_connections
are currently vulnerable to a csrf attack.Implementation is fairly simple. In the view functions we just:
and in the template, when any such form if used, we just add:
@mattupstate wanted to get your opinion on implementation before I work too far on this. @talos will likely also be working with me on it as well, so if any input from either of you would be great.
I was thinking for the first part, we'd want to wrap it in a config check,
app.config['CSRF_ENABLED']
that is set by calling theCsrfProtect
function. It might be useful to also set an override,app.config['SOCIAL_CSRF_ENABLED']
, but this might be overkill and over complicated.Also, the template stuff is obviously a change to Flask-Social-Example. I think it makes sense to turn it on for the example, both since it's a good practice to use something like
CsrfProtect
, and so that we can have the example reflecting that use case.The text was updated successfully, but these errors were encountered: