Skip to content

Commit fa8621f

Browse files
committed
Remove jupyter-server Authentication
1 parent 0d4e701 commit fa8621f

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

jupyter_server_proxy/standalone/proxy.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from jupyterhub import __version__ as __jh_version__
66
from jupyterhub.services.auth import HubOAuthCallbackHandler, HubOAuthenticated
77
from jupyterhub.utils import make_ssl_context
8-
from tornado import httpclient
8+
from tornado import httpclient, web
99
from tornado.web import Application, RedirectHandler
1010
from tornado.websocket import WebSocketHandler
1111

12-
from ..handlers import ProxyHandler, SuperviseAndProxyHandler
12+
from ..handlers import SuperviseAndProxyHandler
1313

1414

1515
def configure_http_client():
@@ -48,7 +48,7 @@ def get_timeout(self):
4848
return self.timeout
4949

5050

51-
class StandaloneHubProxyHandler(StandaloneProxyHandler, HubOAuthenticated):
51+
class StandaloneHubProxyHandler(HubOAuthenticated, StandaloneProxyHandler):
5252
"""
5353
Standalone Proxy used when spawned by a JupyterHub.
5454
Will restrict access to the application by authentication with the JupyterHub API.
@@ -70,9 +70,9 @@ def allow_all(self):
7070
return self.settings["anyone"] == "1"
7171
return super().allow_all
7272

73-
def prepare(self, *args, **kwargs):
74-
# Enable Authentication Check
75-
return ProxyHandler.prepare(self, *args, **kwargs)
73+
@web.authenticated
74+
async def proxy(self, port, path):
75+
return await super().proxy(port, path)
7676

7777
def set_default_headers(self):
7878
self.set_header("X-JupyterHub-Version", __jh_version__)
@@ -130,12 +130,10 @@ def make_app(
130130

131131
options = dict(
132132
debug=debug,
133-
logs=logs,
133+
# Required for JupyterHub Authentication
134+
hub_user=os.environ.get("JUPYTERHUB_USER", ""),
135+
hub_group=os.environ.get("JUPYTERHUB_GROUP", ""),
134136
cookie_secret=os.urandom(32),
135-
user=os.environ.get("JUPYTERHUB_USER") or "",
136-
group=os.environ.get("JUPYTERHUB_GROUP") or "",
137-
anyone=os.environ.get("JUPYTERHUB_ANYONE") or "",
138-
base_url=prefix, # This is a confusing name, sorry
139137
)
140138

141139
if websocket_max_message_size:

0 commit comments

Comments
 (0)