handle hub prefix in HubAuth

This commit is contained in:
Min RK
2017-03-31 17:06:51 +02:00
parent 5e1516189b
commit d1822ee939
3 changed files with 20 additions and 3 deletions

View File

@@ -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.
@@ -153,6 +160,13 @@ class HubAuth(Configurable):
"""
).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"""

View File

@@ -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,
)

View File

@@ -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,