Skip to content

Commit b28f732

Browse files
committed
Various changes:
- Finalize the load private key functionality - Add indicator on nav when a private key is loaded - Remove the fire sans fonts - Change css to use the bootstrap font stack - Logout will clear the localstorage
1 parent 3996c59 commit b28f732

21 files changed

+74
-1045
lines changed

etsd/keys/templates/keys/load_private_key.html

+15-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@
1919
stored to your browser only</u>, i.e it will never be submited to our server.
2020
</p>
2121
<p>
22-
Please be extra careful while Private Key has been loaded to your browser.
22+
You need to select the private key file which must be in the ASCII armored format.
23+
Then enter the private key decryption passphrase. Now you can press the
24+
"validate" button to make sure that they key and passhrase are both correct.
25+
If everything is ok the Private key information section will be filled with some
26+
of the key information or else you will see an error. Finally,
27+
press "load" button to actually load the key to your browser and be able to use it
28+
to decrypt data.
29+
30+
</p>
31+
<p>
32+
<u>Please be extra careful while Private Key has been loaded to your browser.</u>
2333
</p>
2434
{% endblocktrans %}
2535
</div>
@@ -61,8 +71,8 @@ <h5 class="card-title">Private key information</h5>
6171
</div> <!-- card -->
6272
<div class='row'>
6373
<div class="col">
64-
<button id='validateButton' type='button' class='btn btn-primary' >{% trans "Validate" %}</button>
65-
<button id='submitButton' type='button' disabled class='btn btn-success' >{% trans "Submit" %}</button>
74+
<button id='validateButton' type='button' class='btn btn-primary' >{% trans "Validate private key" %}</button>
75+
<button id='submitButton' type='button' disabled class='btn btn-warning' >{% trans "Load private key" %}</button>
6676
<a class='btn btn-secondary' href='{% url "home" %}'>{% trans "Return" %}</a>
6777
</div>
6878
</div>
@@ -75,19 +85,8 @@ <h5 class="card-title">Private key information</h5>
7585
{% endblock %}
7686

7787
{% block extra_script %}
78-
<script src='{% static "openpgp/openpgp.min.js" %}'></script>
79-
<script>
8088

81-
const loadPrivateKey = (async(privateKeyArmored, passphrase) => {
82-
83-
let privateKey = await openpgp.decryptKey({
84-
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
85-
passphrase
86-
});
87-
console.log(privateKey)
88-
return privateKey
89-
90-
})
89+
<script>
9190

9291
$(function() {
9392
let privateKeyArmored = null;
@@ -109,7 +108,7 @@ <h5 class="card-title">Private key information</h5>
109108

110109
fileReader.onload = function () {
111110
privateKeyArmored = fileReader.result;
112-
let privateKey = loadPrivateKey(privateKeyArmored, passphrase).then( key => {
111+
loadPrivateKey(privateKeyArmored, passphrase).then( key => {
113112
$('#id_fingerprint').val(key.getFingerprint())
114113
$('#id_user_id').val(key.getUserIDs().join(','))
115114
$('#id_creation_time').val(key.getCreationTime().toLocaleString('el'))
-38 KB
Binary file not shown.

static/fonts/fira-sans-v9-greek_latin-600.svg

-328
This file was deleted.
-86.9 KB
Binary file not shown.
-38.9 KB
Binary file not shown.
-31.8 KB
Binary file not shown.
-37.5 KB
Binary file not shown.

static/fonts/fira-sans-v9-greek_latin-900.svg

-330
This file was deleted.
-87.5 KB
Binary file not shown.
-38.4 KB
Binary file not shown.
-31.3 KB
Binary file not shown.
Binary file not shown.

static/fonts/fira-sans-v9-greek_latin-regular.svg

-330
This file was deleted.
-79.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

static/styles.css

+7-41
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,15 @@
11

2-
/* fira-sans-regular - greek_latin */
3-
@font-face {
4-
font-family: 'Fira Sans';
5-
font-style: normal;
6-
font-weight: 400;
7-
src: url('fonts/fira-sans-v9-greek_latin-regular.eot'); /* IE9 Compat Modes */
8-
src: local('Fira Sans Regular'), local('FiraSans-Regular'),
9-
url('fonts/fira-sans-v9-greek_latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
10-
url('fonts/fira-sans-v9-greek_latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
11-
url('fonts/fira-sans-v9-greek_latin-regular.woff') format('woff'), /* Modern Browsers */
12-
url('fonts/fira-sans-v9-greek_latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
13-
url('fonts/fira-sans-v9-greek_latin-regular.svg#FiraSans') format('svg'); /* Legacy iOS */
14-
}
15-
/* fira-sans-600 - greek_latin */
16-
@font-face {
17-
font-family: 'Fira Sans';
18-
font-style: normal;
19-
font-weight: 600;
20-
src: url('fonts/fira-sans-v9-greek_latin-600.eot'); /* IE9 Compat Modes */
21-
src: local('Fira Sans SemiBold'), local('FiraSans-SemiBold'),
22-
url('fonts/fira-sans-v9-greek_latin-600.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
23-
url('fonts/fira-sans-v9-greek_latin-600.woff2') format('woff2'), /* Super Modern Browsers */
24-
url('fonts/fira-sans-v9-greek_latin-600.woff') format('woff'), /* Modern Browsers */
25-
url('fonts/fira-sans-v9-greek_latin-600.ttf') format('truetype'), /* Safari, Android, iOS */
26-
url('fonts/fira-sans-v9-greek_latin-600.svg#FiraSans') format('svg'); /* Legacy iOS */
27-
}
28-
/* fira-sans-900 - greek_latin */
29-
@font-face {
30-
font-family: 'Fira Sans';
31-
font-style: normal;
32-
font-weight: 900;
33-
src: url('fonts/fira-sans-v9-greek_latin-900.eot'); /* IE9 Compat Modes */
34-
src: local('Fira Sans Black'), local('FiraSans-Black'),
35-
url('fonts/fira-sans-v9-greek_latin-900.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
36-
url('fonts/fira-sans-v9-greek_latin-900.woff2') format('woff2'), /* Super Modern Browsers */
37-
url('fonts/fira-sans-v9-greek_latin-900.woff') format('woff'), /* Modern Browsers */
38-
url('fonts/fira-sans-v9-greek_latin-900.ttf') format('truetype'), /* Safari, Android, iOS */
39-
url('fonts/fira-sans-v9-greek_latin-900.svg#FiraSans') format('svg'); /* Legacy iOS */
40-
}
412

423
body {
434
color:#011f4b;
44-
font-family:'Fira Sans', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
455
}
466

477
.main-container {
488
margin-top: 5rem;
49-
}
9+
}
10+
11+
.tooltip-inner {
12+
max-width: 350px;
13+
/* If max-width does not work, try using width instead */
14+
width: 350px;
15+
}

static/tools.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Careful. This returns a Promise. Proper usage is:
2+
3+
// loadPrivateKey(...).then(
4+
// privateKey => console.log(privateKey) // RESOVE
5+
// reason => console.log(reason) // REJECT
6+
//).catch(
7+
// err => console.log(err)
8+
//)
9+
const loadPrivateKey = (async(privateKeyArmored, passphrase) => {
10+
let privateKey = await openpgp.decryptKey({
11+
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
12+
passphrase
13+
});
14+
return privateKey
15+
})
16+
17+
const loadPrivateKeyLocal = async () => loadPrivateKey(
18+
localStorage['privateKeyArmored'],localStorage['privateKeyPassphrase']
19+
)
20+
21+
const enableTooltips = () => {
22+
let tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
23+
let tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
24+
return new bootstrap.Tooltip(tooltipTriggerEl)
25+
})
26+
}

templates/logout.html

+6
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@
99
<a href='{% url "home" %}' class='btn btn-primary'>Return</a>
1010
</div>
1111
</div>
12+
{% endblock %}
13+
14+
{% block extra_script %}
15+
<script>
16+
localStorage.clear()
17+
</script>
1218
{% endblock %}

templates/partials/_nav.html

+14
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,23 @@
2323
</div>
2424
</li>
2525
</ul>
26+
2627
<ul class="navbar-nav ">
2728
<li class="nav-item">
2829
{% if user.is_authenticated %}
30+
{% with request.session.private_key_data as pkdata %}
31+
{% if pkdata %}
32+
<a class="btn btn-outline-danger btn-sm"
33+
data-bs-toggle="tooltip"
34+
data-bs-html="true"
35+
data-bs-placement="bottom"
36+
title="Fingerprint: <b>{{ pkdata.fingerprint }}</b><br/>User id: <b>{{ pkdata.user_id|escape }}</b>"
37+
href='#'
38+
>
39+
<b>Private key loaded</b>
40+
</a>
41+
{% endif %}
42+
{% endwith %}
2943
<a class="btn btn-outline-info btn-sm" href="{% url 'auth_logout' %}">{{ user.get_full_name }} ({{ user.username }}) | Disconnect</a>
3044
{% else %}
3145
<a class="btn btn-outline-info btn-sm" href="{% url 'auth_login' %}">Please login</a>

templates/theme_base.html

+6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@
4848
<script src="{% static 'jquery-3.5.1.min.js' %}"></script>
4949
<script src="{% static 'jquery-ui-1.12.1.min.js' %}"></script>
5050
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
51+
<script src='{% static "openpgp/openpgp.min.js" %}'></script>
5152
<script src="{% static 'tools.js' %}"></script>
5253
<script src="{% static 'bootstrapalert.js' %}"></script>
5354
<script
5455
type="text/javascript"
5556
src="{% static 'django_tables2_column_shifter/js/django_tables2_column_shifter.min.js' %}">
5657
</script>
58+
<script>
59+
$(function() {
60+
enableTooltips();
61+
})
62+
</script>
5763
{% endcompress %}
5864
{% endblock %}
5965
{% compress js %}

0 commit comments

Comments
 (0)