Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Flask-Security library due to performance issues #147

Closed
jpowie01 opened this issue Mar 24, 2018 · 0 comments
Closed

Remove Flask-Security library due to performance issues #147

jpowie01 opened this issue Mar 24, 2018 · 0 comments
Assignees
Labels
Backend 🏭 Stuff related to Backend part. Enhancement 🌪 Things that improve our project. P1 Things with #1 Priority

Comments

@jpowie01
Copy link
Member

Expected Behavior

Calling /api/v1/core/status with authentication header should be as fast as possible.

Actual Behavior

Requests with authentication header take waaaaaaay too long!

Steps to Reproduce the Problem

  1. Log in:
$ curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \ 
   "email": "admin%40medtagger.com", \ 
   "password": "medtagger1" \ 
 }' 'http://localhost:51000/api/v1/auth/sign-in'

So now, you know your token:

{
  "token": "WyIxIiwiJDUkcm91bmRzPTUzNTAwMCRWZnppNmVtT1BDZERWQnhSJHFJb0FscGF4T3huczJ5QWI0R0lpQXhNL1ZhbnBSeTVxdmguSUNkOEtQNC4iXQ.DZf7RQ._ktW6C3CJ0uumUm-YVR8LVDj3po"
}
  1. Call API without header:
$ curl -X GET --header 'Accept: application/json' 'http://localhost:51000/api/v1/core/status' -w %{time_connect}:%{time_starttransfer}:%{time_total}

As you can see it was really fast:

{"success": true}
0.015452:0.020297:0.020431%
  1. Call API with token header:
$ curl -X GET --header 'Accept: application/json' --header 'Authentication-Token: WyIxIiwiJDUkcm91bmRzPTUzNTAwMCRWZnppNmVtT1BDZERWQnhSJHFJb0FscGF4T3huczJ5QWI0R0lpQXhNL1ZhbnBSeTVxdmguSUNkOEtQNC4iXQ.DZf7RQ._ktW6C3CJ0uumUm-YVR8LVDj3po' 'http://localhost:51000/api/v1/core/status' -w %{time_connect}:%{time_starttransfer}:%{time_total}

And it takes ages... (1.5 second!):

{"success": true}
0.014786:1.452852:1.452908

Additional comment

Issue on Flask-Security:
pallets-eco/flask-security-3.0#731

Blog post about proper authentication:
https://blog.miguelgrinberg.com/post/restful-authentication-with-flask

An implementation that uses tokens:
https://gist.github.com/gouthambs/0a509faf231cff3cdec7

@jpowie01 jpowie01 added Enhancement 🌪 Things that improve our project. Backend 🏭 Stuff related to Backend part. P1 Things with #1 Priority labels Mar 24, 2018
@jpowie01 jpowie01 assigned kolszewska and jpowie01 and unassigned kolszewska Mar 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend 🏭 Stuff related to Backend part. Enhancement 🌪 Things that improve our project. P1 Things with #1 Priority
Projects
None yet
Development

No branches or pull requests

2 participants