first commit

This commit is contained in:
root
2024-09-20 04:29:09 +00:00
commit 5383007f49
459 changed files with 88755 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
{% extends "mfa/webauthn/base.html" %}
{% load i18n %}
{% load static %}
{% load allauth %}
{% block content %}
{% element h1 %}
{% trans "Add Security Key" %}
{% endelement %}
{% url 'mfa_add_webauthn' as action_url %}
{% element form form=form method="post" action=action_url %}
{% slot body %}
{% csrf_token %}
{% element fields form=form %}
{% endelement %}
{% endslot %}
{% slot actions %}
{% element button id="mfa_webauthn_add" type="button" %}
{% trans "Add" %}
{% endelement %}
{% endslot %}
{% endelement %}
{% include "mfa/webauthn/snippets/scripts.html" %}
{{ js_data|json_script:"js_data" }}
<script>
allauth.webauthn.forms.addForm({
ids: {
add: "mfa_webauthn_add",
passwordless: "{{ form.passwordless.auto_id }}",
credential: "{{ form.credential.auto_id }}"
},
data: JSON.parse(document.getElementById('js_data').textContent)
})
</script>
{% endblock %}

View File

@@ -0,0 +1,18 @@
{% extends "mfa/webauthn/base.html" %}
{% load i18n %}
{% load allauth %}
{% block content %}
{% element h1 %}
{% trans "Remove Security Key" %}
{% endelement %}
<p>{% blocktranslate %}Are you sure you want to remove this security key?{% endblocktranslate %}</p>
{% url 'mfa_remove_webauthn' pk=authenticator.pk as action_url %}
{% element form method="post" action=action_url no_visible_fields=True %}
{% slot actions %}
{% csrf_token %}
{% element button tags="danger" type="submit" %}
{% translate "Remove" %}
{% endelement %}
{% endslot %}
{% endelement %}
{% endblock %}

View File

@@ -0,0 +1,72 @@
{% extends "mfa/webauthn/base.html" %}
{% load i18n %}
{% load static %}
{% load allauth %}
{% load humanize %}
{% block content %}
{% element h1 %}
{% trans "Security Keys" %}
{% endelement %}
{% if authenticators|length == 0 %}
<p>{% blocktranslate %}No security keys have been added.{% endblocktranslate %}</p>
{% else %}
{% element table %}
{% element thead %}
{% element th %}
{% translate "Key" %}
{% endelement %}
{% element th %}
{% translate "Usage" %}
{% endelement %}
{% element th %}
{% endelement %}
{% endelement %}
{% element tbody %}
{% for authenticator in authenticators %}
{% element tr %}
{% element td %}
{{ authenticator }}
{% if authenticator.wrap.is_passwordless is True %}
{% element badge tags="mfa,key,primary" %}
{% translate "Passkey" %}
{% endelement %}
{% elif authenticator.wrap.is_passwordless is False %}
{% element badge tags="mfa,key,secondary" %}
{% translate "Security key" %}
{% endelement %}
{% else %}
{% element badge title=_("This key does not indicate whether it is a passkey.") tags="mfa,key,warning" %}
{% translate "Unspecified" %}
{% endelement %}
{% endif %}
{% endelement %}
{% element td %}
{% blocktranslate with created_at=authenticator.created_at|date:"SHORT_DATE_FORMAT" %}Added on {{ created_at }}{% endblocktranslate %}.
{% if authenticator.last_used_at %}
{% blocktranslate with last_used=authenticator.last_used_at|naturaltime %}Last used {{ last_used }}{% endblocktranslate %}
{% else %}
Not used.
{% endif %}
{% endelement %}
{% element td align="right" %}
{% url 'mfa_edit_webauthn' pk=authenticator.pk as edit_url %}
{% element button tags="mfa,authenticator,edit,tool" href=edit_url %}
{% translate "Edit" %}
{% endelement %}
{% url 'mfa_remove_webauthn' pk=authenticator.pk as remove_url %}
{% element button tags="mfa,authenticator,danger,delete,tool" href=remove_url %}
{% translate "Remove" %}
{% endelement %}
{% endelement %}
{% endelement %}
{% endfor %}
{% endelement %}
{% endelement %}
{% endif %}
{% url 'mfa_add_webauthn' as add_url %}
{% element button href=add_url %}
{% translate "Add" %}
{% endelement %}
</li>
</ul>
{% endblock %}

View File

@@ -0,0 +1,5 @@
{% extends "mfa/base_manage.html" %}
{% load i18n %}
{% block head_title %}
{% trans "Security Keys" %}
{% endblock head_title %}

View File

@@ -0,0 +1,22 @@
{% extends "mfa/webauthn/base.html" %}
{% load i18n %}
{% load static %}
{% load allauth %}
{% block content %}
{% element h1 %}
{% trans "Edit Security Key" %}
{% endelement %}
{% url 'mfa_edit_webauthn' as action_url %}
{% element form form=form method="post" action=action_url %}
{% slot body %}
{% csrf_token %}
{% element fields form=form %}
{% endelement %}
{% endslot %}
{% slot actions %}
{% element button id="mfa_webauthn_edit" type="submit" %}
{% trans "Save" %}
{% endelement %}
{% endslot %}
{% endelement %}
{% endblock %}

View File

@@ -0,0 +1,30 @@
{% extends "account/base_reauthenticate.html" %}
{% load i18n %}
{% load allauth %}
{% block reauthenticate_content %}
{% url 'mfa_reauthenticate_webauthn' as action_url %}
{% element form form=form method="post" action=action_url %}
{% slot body %}
{% csrf_token %}
{% element fields form=form unlabeled=True %}
{% endelement %}
{{ redirect_field }}
{% endslot %}
{% slot actions %}
{% element button id="mfa_webauthn_reauthenticate" type="submit" tags="primary,mfa,login" %}
{% trans "Use a security key" %}
{% endelement %}
{% endslot %}
{% endelement %}
{{ js_data|json_script:"js_data" }}
{% include "mfa/webauthn/snippets/scripts.html" %}
<script type="text/javascript">
allauth.webauthn.forms.authenticateForm({
ids: {
authenticate: "mfa_webauthn_reauthenticate",
credential: "{{ form.credential.auto_id }}"
},
data: JSON.parse(document.getElementById('js_data').textContent)
})
</script>
{% endblock %}

View File

@@ -0,0 +1,14 @@
{% include "mfa/webauthn/snippets/scripts.html" %}
<form id="mfa_login" action="{% url 'mfa_login_webauthn' %}" method="post">
{% csrf_token %}
{{ redirect_field }}
<input type="hidden" name="credential" id="mfa_credential">
</form>
<script type="text/javascript">
allauth.webauthn.forms.loginForm({
ids: {
login: "passkey_login",
credential: "mfa_credential",
}
})
</script>

View File

@@ -0,0 +1,4 @@
{% load i18n static %}
<noscript>{% translate "This functionality requires JavaScript." %}"</noscript>
<script type="text/javascript" src="{% static 'mfa/js/webauthn-json.js' %}"></script>
<script type="text/javascript" src="{% static 'mfa/js/webauthn.js' %}"></script>