I'm really confused how Google App Engine's User's get_current_user() works. I've looked around the internet at a bunch of different guides and tutorials about login and authentication, and many of them mention similar methods.
If there are a million users logged in to my application at the same time, how can that method possibly work? Does each user get their own instance of the server? How does the server know which client it is talking to?
It doesn't make sense to me at all.
When logging in (by clicking on the URL generated by
create_login_url()
) a cookie containing user identifying information is prepared and pushed on the client side, then used in subsequent requests until the user logs out or the cookie expires. Callingget_current_user()
simply checks the cookie existance/information and responds accordingly.On the development server the cookie is named
dev_appserver_login
. I can no longer check the cookie name on GAE as I switched away from the Users API.The actual handling of the cookie seems to happen somewhere on the Users service backend, for example, by looking at the
google/appengine/api/users.py
file in the python SDK:The end point (at least for the development server) seems to somehow land somewhere in
google/appengine/tools/appengine_rpc.py
, for example: