mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 07:23:00 +00:00
Merge pull request #3315 from dtaniwaki/improve-handler
Make Authenticator Custom HTML Flexible
This commit is contained in:
@@ -1101,6 +1101,13 @@ class PAMAuthenticator(LocalAuthenticator):
|
|||||||
else:
|
else:
|
||||||
return super().normalize_username(username)
|
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 [
|
for _old_name, _new_name, _version in [
|
||||||
("check_group_whitelist", "check_group_allowed", "1.2"),
|
("check_group_whitelist", "check_group_allowed", "1.2"),
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
# Distributed under the terms of the Modified BSD License.
|
# Distributed under the terms of the Modified BSD License.
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
from jinja2 import Template
|
||||||
from tornado import web
|
from tornado import web
|
||||||
from tornado.escape import url_escape
|
from tornado.escape import url_escape
|
||||||
from tornado.httputil import url_concat
|
from tornado.httputil import url_concat
|
||||||
@@ -90,17 +91,23 @@ class LoginHandler(BaseHandler):
|
|||||||
"""Render the login page."""
|
"""Render the login page."""
|
||||||
|
|
||||||
def _render(self, login_error=None, username=None):
|
def _render(self, login_error=None, username=None):
|
||||||
return self.render_template(
|
context = {
|
||||||
'login.html',
|
"next": url_escape(self.get_argument('next', default='')),
|
||||||
next=url_escape(self.get_argument('next', default='')),
|
"username": username,
|
||||||
username=username,
|
"login_error": login_error,
|
||||||
login_error=login_error,
|
"login_url": self.settings['login_url'],
|
||||||
custom_html=self.authenticator.custom_html,
|
"authenticator_login_url": url_concat(
|
||||||
login_url=self.settings['login_url'],
|
|
||||||
authenticator_login_url=url_concat(
|
|
||||||
self.authenticator.login_url(self.hub.base_url),
|
self.authenticator.login_url(self.hub.base_url),
|
||||||
{'next': self.get_argument('next', '')},
|
{'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):
|
async def get(self):
|
||||||
|
Reference in New Issue
Block a user