Skip to content

Commit

Permalink
Remove hub_url_public, add hub_url_local
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Oct 30, 2020
1 parent 181efcd commit a23550c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
15 changes: 11 additions & 4 deletions binderhub/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,21 @@ def _default_hub_token(self):
config=True,
)

hub_url_public = Unicode(
hub_url_local = Unicode(
help="""
The public base URL of the JupyterHub instance where users will run if different from hub_url
The base URL of the JupyterHub instance for local/internal traffic
If local/internal network connections from the BinderHub process should access
JupyterHub using a different URL than public/external traffic set this, default
is hub_url
""",
config=True,
)
@default('hub_url_local')
def _default_hub_url_local(self):
return self.hub_url

@validate('hub_url', 'hub_url_public')
@validate('hub_url', 'hub_url_local')
def _add_slash(self, proposal):
"""trait validator to ensure hub_url ends with a trailing slash"""
if proposal.value is not None and not proposal.value.endswith('/'):
Expand Down Expand Up @@ -585,7 +592,7 @@ def initialize(self, *args, **kwargs):
self.launcher = Launcher(
parent=self,
hub_url=self.hub_url,
hub_url_public=self.hub_url_public,
hub_url_local=self.hub_url_local,
hub_api_token=self.hub_api_token,
create_user=not self.auth_enabled,
)
Expand Down
4 changes: 2 additions & 2 deletions binderhub/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Launcher(LoggingConfigurable):

hub_api_token = Unicode(help="The API token for the Hub")
hub_url = Unicode(help="The URL of the Hub")
hub_url_public = Unicode(help="The public URL of the Hub if different")
hub_url_local = Unicode(help="The internal URL of the Hub if different")
create_user = Bool(True, help="Create a new Hub user")
allow_named_servers = Bool(
os.getenv('JUPYTERHUB_ALLOW_NAMED_SERVERS', "false") == "true",
Expand Down Expand Up @@ -241,5 +241,5 @@ async def launch(self, image, username, server_name='', repo_url='', extra_args=
format(_server_name, username, e, body))
raise web.HTTPError(500, "Failed to launch image %s" % image)

data['url'] = (self.hub_url_public or self.hub_url) + 'user/%s/%s' % (username, server_name)
data['url'] = self.hub_url + 'user/%s/%s' % (username, server_name)
return data
3 changes: 1 addition & 2 deletions helm-chart/binderhub/files/binderhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def get_value(key, default=None):
c.BinderHub.build_namespace = os.environ['BUILD_NAMESPACE']

if c.BinderHub.auth_enabled:
hub_url = urlparse(c.BinderHub.hub_url_public if 'hub_url_public' in c.BinderHub
else c.BinderHub.hub_url)
hub_url = urlparse(c.BinderHub.hub_url)
c.HubOAuth.hub_host = '{}://{}'.format(hub_url.scheme, hub_url.netloc)
if 'base_url' in c.BinderHub:
c.HubOAuth.base_url = c.BinderHub.base_url
Expand Down

0 comments on commit a23550c

Please sign in to comment.