Description
Description
In Jupyter Server 2.0 we are deprecating self.get_current_user
in favor of self.current_users
in the handlers. I am tracking down a bug when using Jupyter Server proxy with Jupyter Server 2. My current hypothesis is that Tornado's web.authenticated
decorator gets self.current_user
which results in self.get_current_user()
being called if self._current_user
is not set. The result is that Jupyter Server 2 raises an exception because the deprecated self.get_current_user()
is called.
Reproduce
I don't yet have a simple way of reproducing this yet, but here is a rough sequence of calls that is resulting in this problem:
First, when Jupyter Server proxy receives a request that needs to be proxied, the self.proxy()
method of ProxyHandler
gets called:
https://github.com/jupyterhub/jupyter-server-proxy/blob/main/jupyter_server_proxy/handlers.py#L269
This method is decorated with Tornado's web.authenticated
decorator. This decorator, retrieves the value of self.current_user
here:
https://github.com/tornadoweb/tornado/blob/master/tornado/web.py#L3194
When self._current_user
is not set, Tornado itself calls self.get_current_user()
here:
https://github.com/tornadoweb/tornado/blob/master/tornado/web.py#L1344
There are two related issues I believe:
- First, the
self.prepare()
method in Jupyter Server's handler appears to have logic that will ensure thatself.current_user
is set. It is likely that the handler logic in Jupyter Server Proxy is resulting inprepare
not being called early enough or that the logic to setcurrent_user
is too late withinprepare
. - More importantly, I think there is a deeper problem that may cause problems for us. This is that
self.get_current_user()
is a public API of the base Tornado handler (see here). I am not sure what it means for our subclass of the Tornado handler class to deprecate a public method in the base class. We can tell people to not call it when using our subclass, but Tornado itself can still call it (as in this case).
Expected behavior
Jupyter Server proxy, which doesn't directly call self.get_current_user()
should work without modification with Jupyter Server 2.