-
Notifications
You must be signed in to change notification settings - Fork 62
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
Calls to firebase_auth.get_user() can add 100-200ms to request time #28
Comments
Hi @keeth , I will have to get my head into the context to be able to answer the Cheers |
I've looked a bit into this question, here are the result of my investigation, so that if someone is interested in solving this, s.he can have more info on this. At the moment, when a request is received by Django,
The step in bold includes a request to Firebase. What it truly should be doing is:
That way, a trip to Firebase is only needed during local user creation. In case the local user creation doesn't require data from the firebase user, a request to Firebase is not even needed. I'll try to create a PR if I get the time to do this. |
My solution was to always just use the token. For my purposes it has enough info even for account creation..
|
The best would to let it the user choose whether they need to fetch the firebase user. |
Hey guys this is still on my radar, just need to find time to get my head into it. Thanks for the feedback so far! If there is some sort of consensus re: best way forward and I haven't gotten to it yet, feel free to make a pull req. Have opened a ticket in Trello to track this, feel free to add code snippets/screenshots/more info |
Hi,
Just reviewing my web API performance and found high latency whenever firebase_auth.get_user() is called, since it sends a blocking HTTP request to the Firebase Auth API.
I've read a few different Python Firebase Auth tutorials and they all just use the decoded JWT to supply user data, they do not make a call out to the Firebase web API. This makes sense since a synchronous HTTP call is bad for performance.
If
FIREBASE_CHECK_JWT_REVOKED
is enabled, the get_user() call is made twice per request cycle. One of these calls is surely redundant.Apart from revocation is there a reason to fetch the user rather than using the properties that are already embedded in the JWT?
Thanks!
The text was updated successfully, but these errors were encountered: