2020-05-05 08:32:49 +00:00
|
|
|
{% extends 'default.html' %}
|
|
|
|
{% set active_page = "setting" %}
|
|
|
|
{% block title %}
|
|
|
|
Security Key Setup
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block head %}
|
|
|
|
<script src="{{ url_for('static', filename='node_modules/qrious/dist/qrious.min.js') }}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='assets/js/vendors/base64.js') }}"></script>
|
2020-05-24 22:10:12 +00:00
|
|
|
<script src="/static/assets/js/vendors/webauthn.js?v={{ VERSION }}"></script>
|
2020-05-05 08:32:49 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block default_content %}
|
2020-05-11 21:22:06 +00:00
|
|
|
<div class="card">
|
|
|
|
<div class="card-body">
|
|
|
|
<h1 class="h2 text-center">Register Your Security Key</h1>
|
|
|
|
<p class="text-center">Follow your browser's steps to register your security key with SimpleLogin</p>
|
|
|
|
|
|
|
|
<form id="formRegisterKey" method="post">
|
|
|
|
{{ fido_token_form.csrf_token }}
|
|
|
|
{{ fido_token_form.sk_assertion(class="form-control", placeholder="") }}
|
2020-05-18 09:55:41 +00:00
|
|
|
|
|
|
|
{{ fido_token_form.key_name(class="form-control", placeholder="Name of your key (Required)") }}
|
|
|
|
{{ render_field_errors(fido_token_form.key_name) }}
|
2020-05-18 20:45:02 +00:00
|
|
|
|
|
|
|
<div class="text-center">
|
|
|
|
<button id="btnRegisterKey" class="btn btn-lg btn-primary mt-2" onclick="registerKey();">Register Key</button>
|
|
|
|
</div>
|
2020-05-11 21:22:06 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
async function registerKey() {
|
|
|
|
$("#btnRegisterKey").prop('disabled', true);
|
|
|
|
$("#btnRegisterKey").text('Waiting for Security Key...');
|
|
|
|
|
|
|
|
const pkCredentialCreateOptions = transformCredentialCreateOptions(
|
|
|
|
JSON.parse('{{credential_create_options|tojson|safe}}')
|
|
|
|
)
|
|
|
|
|
2020-05-18 05:05:37 +00:00
|
|
|
|
2020-05-11 21:22:06 +00:00
|
|
|
let credential
|
|
|
|
try {
|
|
|
|
credential = await navigator.credentials.create({
|
|
|
|
publicKey: pkCredentialCreateOptions
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
toastr.error("An error occurred when we trying to register your key.");
|
|
|
|
$("#btnRegisterKey").prop('disabled', false);
|
|
|
|
$("#btnRegisterKey").text('Register Key');
|
|
|
|
return console.error("Error when trying to create credential:", err);
|
|
|
|
}
|
|
|
|
|
|
|
|
const skAssertion = transformNewAssertionForServer(credential);
|
|
|
|
|
|
|
|
$('#sk_assertion').val(JSON.stringify(skAssertion));
|
|
|
|
$('#formRegisterKey').submit();
|
2020-05-05 08:32:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-11 21:22:06 +00:00
|
|
|
</script>
|
2020-05-05 08:32:49 +00:00
|
|
|
|
2020-05-11 21:22:06 +00:00
|
|
|
</div>
|
2020-05-05 08:32:49 +00:00
|
|
|
</div>
|
|
|
|
{% endblock %}
|