mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-14 13:33:00 +00:00
more informative error if single-user server can't connect to Hub for auth
error message points to hub_ip setting if Hub doesn't appear to be accessible at 127.0.0.1
This commit is contained in:
@@ -7,6 +7,7 @@ HubAuth can be used in any application, even outside tornado.
|
||||
HubAuthenticated is a mixin class for tornado handlers that should authenticate with the Hub.
|
||||
"""
|
||||
|
||||
import socket
|
||||
import time
|
||||
from urllib.parse import quote
|
||||
|
||||
@@ -148,12 +149,25 @@ class HubAuth(Configurable):
|
||||
cached = self.cookie_cache.get(encrypted_cookie)
|
||||
if cached is not None:
|
||||
return cached
|
||||
|
||||
r = requests.get(url_path_join(
|
||||
self.api_url, "authorizations/cookie", self.cookie_name, quote(encrypted_cookie, safe=''),
|
||||
try:
|
||||
r = requests.get(
|
||||
url_path_join(self.api_url,
|
||||
"authorizations/cookie",
|
||||
self.cookie_name,
|
||||
quote(encrypted_cookie, safe=''),
|
||||
),
|
||||
headers = {'Authorization' : 'token %s' % self.api_token},
|
||||
headers = {
|
||||
'Authorization' : 'token %s' % self.api_token,
|
||||
},
|
||||
)
|
||||
except requests.ConnectionError:
|
||||
msg = "Failed to connect to Hub API at %r." % self.api_url
|
||||
msg += " Is the Hub accessible at this URL (from host: %s)?" % socket.gethostname()
|
||||
if '127.0.0.1' in self.api_url:
|
||||
msg += " Make sure to set c.JupyterHub.hub_ip to an IP accessible to" + \
|
||||
" single-user servers if the servers are not on the same host as the Hub."
|
||||
raise HTTPError(500, msg)
|
||||
|
||||
if r.status_code == 404:
|
||||
data = None
|
||||
elif r.status_code == 403:
|
||||
|
Reference in New Issue
Block a user