diff --git a/jupyterhub/auth.py b/jupyterhub/auth.py index 33a00bef..09d09a02 100644 --- a/jupyterhub/auth.py +++ b/jupyterhub/auth.py @@ -1101,6 +1101,13 @@ class PAMAuthenticator(LocalAuthenticator): else: return super().normalize_username(username) + def get_custom_html(self, base_url): + """Get custom HTML for the authenticator. + + .. versionadded: 1.4 + """ + return self.custom_html + for _old_name, _new_name, _version in [ ("check_group_whitelist", "check_group_allowed", "1.2"), diff --git a/jupyterhub/handlers/login.py b/jupyterhub/handlers/login.py index 605cd580..29f2ff02 100644 --- a/jupyterhub/handlers/login.py +++ b/jupyterhub/handlers/login.py @@ -3,6 +3,7 @@ # Distributed under the terms of the Modified BSD License. import asyncio +from jinja2 import Template from tornado import web from tornado.escape import url_escape from tornado.httputil import url_concat @@ -90,17 +91,23 @@ class LoginHandler(BaseHandler): """Render the login page.""" def _render(self, login_error=None, username=None): - return self.render_template( - 'login.html', - next=url_escape(self.get_argument('next', default='')), - username=username, - login_error=login_error, - custom_html=self.authenticator.custom_html, - login_url=self.settings['login_url'], - authenticator_login_url=url_concat( + context = { + "next": url_escape(self.get_argument('next', default='')), + "username": username, + "login_error": login_error, + "login_url": self.settings['login_url'], + "authenticator_login_url": url_concat( self.authenticator.login_url(self.hub.base_url), {'next': self.get_argument('next', '')}, ), + } + custom_html = Template( + self.authenticator.get_custom_html(self.hub.base_url) + ).render(**context) + return self.render_template( + 'login.html', + **context, + custom_html=custom_html, ) async def get(self):