Skip to content

Commit 28d82ab

Browse files
authored
Merge pull request #295 from blink1073/login-page-deluxe
Add a minimal login page with info
2 parents 3bad90f + 85ce667 commit 28d82ab

File tree

2 files changed

+88
-4
lines changed

2 files changed

+88
-4
lines changed

jupyter_server/templates/login.html

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,98 @@
11
{% extends "page.html" %}
22

3+
{% block stylesheet %}
4+
<style>
5+
.form {
6+
margin-left: 50px;
7+
margin-right: 50px;
8+
}
9+
10+
.content {
11+
margin-left: 50px;
12+
margin-right: 50px;
13+
margin-bottom: 50px;
14+
}
15+
</style>
16+
{% endblock %}
17+
318
{% block site %}
419
{% if message %}
520
{% for key in message %}
6-
<div>
21+
<div class="content">
722
{{message[key]}}
823
</div>
924
{% endfor %}
1025
{% endif %}
11-
<form action="{{base_url}}login?next={{next}}" method="post">
26+
<form class="form" action="{{base_url}}login?next={{next}}" method="post">
1227
{{ xsrf_form_html() | safe }}
13-
<label for="password_input"><strong>{% trans %}Password:{% endtrans %}</strong></label>
28+
<label for="password_input"><strong>{% trans %}Password or token:{% endtrans %}</strong></label>
1429
<input type="password" name="password" id="password_input">
1530
<button type="submit" id="login_submit">{% trans %}Log in{% endtrans %}</button>
1631
</form>
17-
{% endblock site %}
32+
33+
{% if token_available %}
34+
{% block token_message %}
35+
<div class="content">
36+
<h3>
37+
Token authentication is enabled
38+
</h3>
39+
<p>
40+
If no password has been configured, you need to open the
41+
server with its login token in the URL, or paste it above.
42+
This requirement will be lifted if you
43+
<b><a href='https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html'>
44+
enable a password</a></b>.
45+
</p>
46+
<p>
47+
The command:
48+
<pre>jupyter server list</pre>
49+
will show you the URLs of running servers with their tokens,
50+
which you can copy and paste into your browser. For example:
51+
</p>
52+
<pre>Currently running servers:
53+
http://localhost:8888/?token=c8de56fa... :: /Users/you/notebooks
54+
</pre>
55+
<p>
56+
or you can paste just the token value into the password field on this
57+
page.
58+
</p>
59+
<p>
60+
See
61+
<b><a href='https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html'>
62+
the documentation on how to enable a password</a>
63+
</b>
64+
in place of token authentication,
65+
if you would like to avoid dealing with random tokens.
66+
</p>
67+
<p>
68+
Cookies are required for authenticated access to notebooks.
69+
</p>
70+
{% if allow_password_change %}
71+
<h3>{% trans %}Setup a Password{% endtrans %}</h3>
72+
<p> You can also setup a password by entering your token and a new password
73+
on the fields below:</p>
74+
<form action="{{base_url}}login?next={{next}}" method="post" class="">
75+
{{ xsrf_form_html() | safe }}
76+
<div class="form-group">
77+
<label for="token_input">
78+
<h4>Token</h4>
79+
</label>
80+
<input type="password" name="password" id="token_input" class="form-control">
81+
</div>
82+
<div class="form-group">
83+
<label for="new_password_input">
84+
<h4>New Password</h4>
85+
</label>
86+
<input type="password" name="new_password" id="new_password_input" class="form-control" required>
87+
</div>
88+
<div class="form-group">
89+
<button type="submit" class="btn btn-default" id="login_new_pass_submit">{% trans %}Log in and set new
90+
password{% endtrans %}</button>
91+
</div>
92+
</form>
93+
{% endif %}
94+
</div>
95+
{% endblock token_message %}
96+
{% endif %}
97+
98+
{% endblock site %}

jupyter_server/templates/page.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
1111
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1212

13+
{% block stylesheet %}
14+
{% endblock %}
15+
1316
{% block meta %}
1417
{% endblock %}
1518

0 commit comments

Comments
 (0)