diff --git a/jupyterhub/services/auth.py b/jupyterhub/services/auth.py index 09bd4486..6a706306 100644 --- a/jupyterhub/services/auth.py +++ b/jupyterhub/services/auth.py @@ -145,6 +145,13 @@ class HubAuth(Configurable): Typically http://hub-ip:hub-port/hub/api """ ).tag(config=True) + @default('api_url') + def _api_url(self): + env_url = os.getenv('JUPYTERHUB_API_URL') + if env_url: + return env_url + else: + return 'http://127.0.0.1:8081' + url_path_join(self.hub_prefix, 'api') api_token = Unicode(os.getenv('JUPYTERHUB_API_TOKEN', ''), help="""API key for accessing Hub API. @@ -152,7 +159,14 @@ class HubAuth(Configurable): Generate with `jupyterhub token [username]` or add to JupyterHub.services config. """ ).tag(config=True) - + + hub_prefix = Unicode('/hub/', + help="""The URL prefix for the Hub itself. + + Typically /hub/ + """ + ).tag(config=True) + login_url = Unicode('/hub/login', help="""The login URL to use @@ -161,7 +175,7 @@ class HubAuth(Configurable): ).tag(config=True) @default('login_url') def _default_login_url(self): - return self.hub_host + '/hub/login' + return self.hub_host + url_path_join(self.hub_prefix, 'login') cookie_name = Unicode('jupyterhub-services', help="""The name of the cookie I should be looking for""" @@ -417,6 +431,9 @@ class HubOAuth(HubAuth): oauth_authorization_url = Unicode('/hub/api/oauth2/authorize', help="The URL to redirect to when starting the OAuth process", ).tag(config=True) + @default('oauth_authorization_url') + def _auth_url(self): + return self.hub_host + url_path_join(self.hub_prefix, 'api/oauth2/authorize') oauth_token_url = Unicode( help="""The URL for requesting an OAuth token from JupyterHub""" diff --git a/jupyterhub/singleuser.py b/jupyterhub/singleuser.py index ba9ecd0a..0019d386 100755 --- a/jupyterhub/singleuser.py +++ b/jupyterhub/singleuser.py @@ -340,6 +340,7 @@ class SingleUserNotebookApp(NotebookApp): parent=self, api_token=api_token, api_url=self.hub_api_url, + hub_prefix=self.hub_prefix, base_url=self.base_url, ) diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index d25af802..ba581a72 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -495,7 +495,6 @@ class Spawner(LoggingConfigurable): """ args = [ '--user="%s"' % self.user.name, - '--cookie-name="%s"' % self.user.server.cookie_name, '--base-url="%s"' % self.user.server.base_url, '--hub-host="%s"' % self.hub.host, '--hub-prefix="%s"' % self.hub.server.base_url,