Manually authentication
Hi. I use Flask-Security and want to implement api authentication, but I can't login throw bultin views. For example I try(example in #30):
curl -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]", "password":"1234Qwer"}' localhost:5000/login
but got:
{
"meta": {
"code": 400
},
"response": {
"errors": {
"csrf_token": [
"CSRF token missing"
]
}
}
}
I undestand, that I need csrf_token, but for api use it's not needed. Is there way to manually authenticate user or other way to do this? Thanks for the great app:)
Fixed and released in 1.5.4. Which is now on pypi
@mattupstate I'm still getting this error. I'm running 1.6.3, looking through the commit history it seems that this might have been reintroduces in this commit:
https://github.com/mattupstate/flask-security/commit/34b3bf9e8060c73b78fdfeef273e00efa3feb207#flask_security/forms.py
I'm not quite sure how to handle this now, thoughts?
I've done this and that seems to fix it but not sure if that was removed for a reason:
class Form(BaseForm):
def __init__(self, *args, **kwargs):
if current_app.testing:
self.TIME_LIMIT = None
csrf_enabled = request.json is None
kwargs.setdefault('csrf_enabled', csrf_enabled)
super(Form, self).__init__(*args, **kwargs)
@jurre It was removed for security reasons. Accepting a login request from anywhere without the CSRF token is a little sketchy.
What type of client is this? Browser based? Mobile app?
It will be a mobile app but I'm just testing with cURL for now
I would recommend checking out these guidelines: https://developers.google.com/accounts/docs/MobileApps
Thanks :)