diff --git a/dlauthenticator/dlauthenticator.py b/dlauthenticator/dlauthenticator.py index fe2f1d0..fb5396a 100644 --- a/dlauthenticator/dlauthenticator.py +++ b/dlauthenticator/dlauthenticator.py @@ -4,8 +4,8 @@ # GCDLAUTHENTICATOR -- GC JupyterHub authenticator - ISS -__version__ = '0.4.0' -__author__ = 'Mike Fitzpatrick ' +__version__ = '0.4.1' +__author__ = 'Mike Fitzpatrick ' import os @@ -29,17 +29,18 @@ if DEF_SERVICE_ROOT is None: THIS_HOST = socket.gethostname() - if THIS_HOST[:5] == 'dldev': - DEF_SERVICE_ROOT = "https://dldev.datalab.noirlab.edu" - elif THIS_HOST[:6] == 'dltest': - DEF_SERVICE_ROOT = "https://dltest.datalab.noirlab.edu" + if THIS_HOST[:4] == 'gp02': + DEF_SERVICE_ROOT = f"https://gp02.datalab.noirlab.edu" else: - DEF_SERVICE_ROOT = "https://datalab.noirlab.edu" + DEF_SERVICE_ROOT = f"https://datalab.noirlab.edu" # Typically the terraform environment will set the # JHUB_DN_NAME env variable JHUB_DNS_NAME = os.environ.get('JHUB_DNS_NAME') -if JHUB_DNS_NAME is None: +if THIS_HOST[:4] == 'gp02': + DEF_SERVICE_ROOT = f"https://datalab.noirlab.edu" + DL_LOGIN_NEXT_URL = f"https://gp02.datalab.noirlab.edu" +elif JHUB_DNS_NAME is None: DL_LOGIN_NEXT_URL = f"{DEF_SERVICE_ROOT}/devbooks/" else: DL_LOGIN_NEXT_URL = f"https://{JHUB_DNS_NAME}" @@ -47,6 +48,7 @@ DEF_SERVICE_URL = DEF_SERVICE_ROOT + "/auth" + # Make the runtime path to the debug user file accessible only to somebody # with admin privs on the machine running the authenticator. @@ -165,15 +167,19 @@ def post_authenticate(self, handler, data, token): class DataLabAuthenticator(BaseDataLabAuthenticator): """ Data Lab Jupyter token authenticator. - Notice this class doesn't perform a log in proper, that happens on the datalab login - form, which sets a cookie with the login token in the browser, is that token the - one that is used in the is class to authenticate the user. + Notice this class doesn't perform a log in proper, that happens on the + datalab login form, which sets a cookie with the login token in the + browser, is that token the one that is used in the is class to + authenticate the user. """ post_logout_url = f"{DEF_SERVICE_ROOT}/account/logout.html" invalid_token_url = f"{DEF_SERVICE_ROOT}/account/login.html?next={DL_LOGIN_NEXT_URL}" def __init__(self, parent=None, db=None, _deprecated_db_session=None): self.auto_login = True + self.log.info(f"THIS_HOST :{THIS_HOST}") + self.log.info(f"DEF_SERVICE_URL :{DEF_SERVICE_URL}") + self.log.info(f"DL_LOGIN_NEXT_URL :{DL_LOGIN_NEXT_URL}") @gen.coroutine def authenticate(self, handler, data): @@ -188,6 +194,8 @@ def authenticate(self, handler, data): # if we do not have the token then we can just route to login if dl_token is None: + self.log.info(f"NULL token :{dl_token}") + self.log.info(f"NULL redirect :{self.invalid_token_url}") handler.redirect(self.invalid_token_url) return None @@ -207,6 +215,8 @@ def authenticate(self, handler, data): self.log.info(f"Using debug user info for user:{username}") return self.post_authenticate(handler, debug_user_info, None) + self.log.info(f"Invalid token redirect :{dl_token}") + self.log.info(f"Invalid redirect :{self.invalid_token_url}") handler.redirect(self.invalid_token_url) return None else: diff --git a/setup.py b/setup.py index b0cb182..6f6155f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='dlauthenticator', - version='0.4.0', + version='0.4.2', description='Data Lab Authenticator for JupyterHub', url='https://github.com/astro-datalab/dlauthenticator', author='Mike Fitzpatrick',