add "Login with..." button

for custom authenticators that use external services (e.g. OAuth)
This commit is contained in:
Min RK
2015-03-21 20:12:35 -04:00
parent 24fd843c3c
commit 1bc8d50261
4 changed files with 26 additions and 2 deletions

View File

@@ -30,7 +30,18 @@ class Authenticator(LoggingConfigurable):
If empty, allow any user to attempt login.
"""
)
custom_html = Unicode('')
custom_html = Unicode('',
help="""HTML login form for custom handlers.
Override in form-based custom authenticators
that don't use username+password,
or need custom branding.
"""
)
login_service = Unicode('',
help="""Name of the login service for external
login services (e.g. 'GitHub').
"""
)
@gen.coroutine
def authenticate(self, handler, data):

View File

@@ -309,6 +309,7 @@ class BaseHandler(RequestHandler):
prefix=self.base_url,
user=user,
login_url=self.settings['login_url'],
login_service=self.authenticator.login_service,
logout_url=self.settings['logout_url'],
static_url=self.static_url,
version_hash=self.version_hash,

View File

@@ -2,6 +2,13 @@
display: table;
height: 80vh;
.service-login {
text-align: center;
display: table-cell;
vertical-align: middle;
margin: auto auto 20% auto;
}
form {
display: table-cell;
vertical-align: middle;

View File

@@ -9,6 +9,12 @@
<div id="login-main" class="container">
{% if custom_html %}
{{ custom_html }}
{% elif login_service %}
<div class="service-login">
<a class='btn btn-jupyter btn-lg' href='{{login_url}}'>
Sign in with {{login_service}}
</a>
</div>
{% else %}
<form action="{{login_url}}?next={{next}}" method="post" role="form">
<div class="auth-form-header">
@@ -51,7 +57,6 @@
</div>
</form>
{% endif %}
{% endif %}
</div>
{% endblock login %}