Compare commits
18 Commits
MoreOption
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
972ccf4888 | ||
|
|
044f52da6a | ||
|
|
b1a167ad66 | ||
|
|
70dd692299 | ||
|
|
a1855d3998 | ||
|
|
16537baa6f | ||
|
|
e76feeb06b | ||
|
|
e0335ac4a7 | ||
|
|
54f5eb212a | ||
|
|
c53b4d1e1a | ||
|
|
0075f84b29 | ||
|
|
6ae4c2508c | ||
|
|
41256cc76d | ||
| b94faa1916 | |||
|
|
be3cf69956 | ||
|
|
98b9fce1d2 | ||
|
|
17ef0f4b1e | ||
|
|
669fef84fd |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,5 +1,9 @@
|
||||
.idea
|
||||
example/venv
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
@@ -105,3 +109,6 @@ venv.bak/
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
example/test_db
|
||||
|
||||
# OS related
|
||||
.DS_Store
|
||||
|
||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,4 +1,17 @@
|
||||
# Change Log
|
||||
## 2.9.0
|
||||
* Fix a typo,
|
||||
|
||||
Thanks to @jkirkcaldy
|
||||
|
||||
## 2.8.0
|
||||
* Support For Django 4.0+ JSONField
|
||||
* Removed jsonfield package from requirements
|
||||
|
||||
## 2.7.0
|
||||
* Fixed #70
|
||||
* Add QR Code for trusted device link
|
||||
* Better formatting for trusted device start page.
|
||||
## 2.6.1
|
||||
* Fix: CVE-2022-42731: related to the possibility of registration replay attack.
|
||||
Thanks to 'SSE (Secure Systems Engineering)'
|
||||
|
||||
58
README.md
58
README.md
@@ -11,6 +11,7 @@ A Django app that handles MFA, it supports TOTP, U2F, FIDO2 U2F (Web Authn), Ema
|
||||
[](https://anaconda.org/conda-forge/django-mfa2)
|
||||
[](https://anaconda.org/conda-forge/django-mfa2)
|
||||
|
||||
|
||||
Web Authencation API (WebAuthn) is state-of-the art techology that is expected to replace passwords.
|
||||
|
||||

|
||||
@@ -22,7 +23,9 @@ For FIDO2, the following are supported
|
||||
* **android-safetynet** (Chrome 70+, Firefox 68+)
|
||||
* **NFC devices using PCSC** (Not Tested, but as supported in fido2)
|
||||
* **Soft Tokens**
|
||||
* [krypt.co](https://krypt.co/): Login by a notification on your phone.
|
||||
* ~~[krypt.co](https://krypt.co/): Login by a notification on your phone.~~
|
||||
|
||||
**Update**: Dec 2022, krypt.co has been killed by Google for Passkeys.
|
||||
|
||||
In English :), It allows you to verify the user by security keys on PC, Laptops or Mobiles, Windows Hello (Fingerprint, PIN) on Windows 10 Build 1903+ (May 2019 Update) Touch/Face ID on Macbooks (Chrome, Safari), Touch/Face ID on iPhone and iPad and Fingerprint/Face/Iris/PIN on Android Phones.
|
||||
|
||||
@@ -32,6 +35,8 @@ Trusted device is a mode for the user to add a device that doesn't support secur
|
||||
|
||||
Package tested with Django 1.8, Django 2.2 on Python 2.7 and Python 3.5+ but it was not checked with any version in between but open for issues.
|
||||
|
||||
If you just need WebAuthn and Passkeys, you can use **[django-passkeys](https://github.com/mkalioby/django-passkeys)**, which is a slim-down of this app and much easier to integrate.
|
||||
|
||||
Depends on
|
||||
|
||||
* pyotp
|
||||
@@ -43,8 +48,12 @@ Depends on
|
||||
|
||||
# Installation
|
||||
1. using pip
|
||||
* For Django >= 4.0
|
||||
|
||||
`pip install django-mfa2`
|
||||
* For Django < 4.0
|
||||
|
||||
`pip install django-mfa2 jsonfield`
|
||||
2. Using Conda forge
|
||||
|
||||
`conda config --add channels conda-forge`
|
||||
@@ -90,10 +99,6 @@ Depends on
|
||||
U2F_APPID="https://localhost" #URL For U2F
|
||||
FIDO_SERVER_ID=u"localehost" # Server rp id for FIDO2, it is the full domain of your project
|
||||
FIDO_SERVER_NAME=u"PROJECT_NAME"
|
||||
MFA_FIDO2_RESIDENT_KEY = mfa.ResidentKey.DISCOURAGED # Resident Key allows a special User Handle
|
||||
MFA_FIDO2_AUTHENTICATOR_ATTACHMENT = None # Let the user choose
|
||||
MFA_FIDO2_USER_VERIFICATION = None # Verify User Presence
|
||||
MFA_FIDO2_ATTESTATION_PREFERENCE = mfa.AttestationPreference.NONE
|
||||
```
|
||||
**Method Names**
|
||||
* U2F
|
||||
@@ -108,10 +113,8 @@ Depends on
|
||||
* Starting version 1.7.0, Key owners can be specified.
|
||||
* Starting version 2.2.0
|
||||
* Added: `MFA_SUCCESS_REGISTRATION_MSG` & `MFA_REDIRECT_AFTER_REGISTRATION`
|
||||
* Starting version 2.6.0
|
||||
Start version 2.6.0
|
||||
* Added: `MFA_ALWAYS_GO_TO_LAST_METHOD`, `MFA_RENAME_METHODS`, `MFA_ENFORCE_RECOVERY_METHOD` & `RECOVERY_ITERATION`
|
||||
* Starting version 2.7.0
|
||||
* Added: `MFA_FIDO2_RESIDENT_KEY`, `MFA_FIDO2_AUTHENTICATOR_ATTACHMENT`, `MFA_FIDO2_USER_VERIFICATION`, `MFA_FIDO2_ATTESTATION_PREFERENCE`
|
||||
4. Break your login function
|
||||
|
||||
Usually your login function will check for username and password, log the user in if the username and password are correct and create the user session, to support mfa, this has to change
|
||||
@@ -194,6 +197,43 @@ function some_func() {
|
||||
|
||||
````
|
||||
|
||||
# Testing
|
||||
|
||||
We use `pytest` and several pytest plugins, especially the `pytest-django` and `pytest-cov` plugins that provide Django fixtures, and test coverage analysis.
|
||||
|
||||
In the root folder, `pytest.ini` contains configurations for running the tests, `requirements_testing.txt` contains the python packages required for running tests, and the folder `tests` contains the actual test files.
|
||||
|
||||
To run the tests, install the packages in requirements and requirements_testing.txt:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt -r requirements_testing.txt
|
||||
```
|
||||
|
||||
then simply run pytest
|
||||
```
|
||||
pytest
|
||||
```
|
||||
|
||||
to generate the coverage html pages:
|
||||
|
||||
```
|
||||
pytest --cov=. --cov-report html -v
|
||||
```
|
||||
|
||||
the coverage html files will be generated in the `htmlcov` folder
|
||||
|
||||
We use `tox` to test the package against different isolated environments. `tox.ini` contains the configurations for tox. To run the tests in the environments defined in the `tox.ini` file, make sure the python package tox is installed:
|
||||
|
||||
```
|
||||
pip install tox
|
||||
```
|
||||
|
||||
then run tox in the project root:
|
||||
|
||||
```
|
||||
tox
|
||||
```
|
||||
|
||||
# Contributors
|
||||
* [mahmoodnasr](https://github.com/mahmoodnasr)
|
||||
* [d3cline](https://github.com/d3cline)
|
||||
@@ -205,6 +245,8 @@ function some_func() {
|
||||
* [ezrajrice](https://github.com/ezrajrice)
|
||||
* [Spitfireap](https://github.com/Spitfireap)
|
||||
* [peterthomassen](https://github.com/peterthomassen)
|
||||
* [oussjarrousse](https://github.com/oussjarrousse)
|
||||
* [jkirkcaldy](https://github.com/jkirkcaldy)
|
||||
|
||||
|
||||
# Security contact information
|
||||
|
||||
@@ -13,8 +13,6 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
|
||||
import os
|
||||
from django.conf.global_settings import PASSWORD_HASHERS as DEFAULT_PASSWORD_HASHERS
|
||||
|
||||
import mfa
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
@@ -147,10 +145,6 @@ MFA_REDIRECT_AFTER_REGISTRATION="registered"
|
||||
MFA_SUCCESS_REGISTRATION_MSG="Go to Home"
|
||||
MFA_ALWAYS_GO_TO_LAST_METHOD = True
|
||||
MFA_ENFORCE_RECOVERY_METHOD = True
|
||||
MFA_FIDO2_RESIDENT_KEY = mfa.ResidentKey.REQUIRED # Resident Key allows a special User Handle
|
||||
MFA_FIDO2_AUTHENTICATOR_ATTACHMENT = None # Let the user choose
|
||||
MFA_FIDO2_USER_VERIFICATION = None # Verify User Presence
|
||||
MFA_FIDO2_ATTESTATION_PREFERENCE = mfa.AttestationPreference.NONE
|
||||
MFA_RENAME_METHODS = {"RECOVERY":"Backup Codes","FIDO2":"Biometric Authentication"}
|
||||
PASSWORD_HASHERS = DEFAULT_PASSWORD_HASHERS #Comment if PASSWORD_HASHER already set
|
||||
PASSWORD_HASHERS += ['mfa.recovery.Hash']
|
||||
|
||||
@@ -44,9 +44,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary btn-block" type="submit">Login</button><br/>
|
||||
|
||||
<button class="btn btn-primary btn-block" type="button" onclick="authen()">Login By Security Key</button>
|
||||
<button class="btn btn-primary btn-block" type="submit">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,7 +56,7 @@
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="{% static 'vendor/jquery-easing/jquery.easing.min.js'%}"></script>
|
||||
{% include 'FIDO2/Auth_JS.html'%}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -16,12 +16,13 @@ Including another URLconf
|
||||
from django.contrib import admin
|
||||
from django.urls import path,re_path,include
|
||||
from . import views,auth
|
||||
from mfa import TrustedDevice
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('mfa/', include('mfa.urls')),
|
||||
path('auth/login',auth.loginView,name="login"),
|
||||
path('auth/logout',auth.logoutView,name="logout"),
|
||||
|
||||
path('devices/add/', TrustedDevice.add,name="add_trusted_device"),
|
||||
re_path('^$',views.home,name='home'),
|
||||
path('registered/',views.registered,name='registered')
|
||||
]
|
||||
|
||||
38
mfa/FIDO2.py
38
mfa/FIDO2.py
@@ -28,25 +28,18 @@ def recheck(request):
|
||||
|
||||
def getServer():
|
||||
"""Get Server Info from settings and returns a Fido2Server"""
|
||||
from mfa import AttestationPreference
|
||||
rp = PublicKeyCredentialRpEntity(id=settings.FIDO_SERVER_ID, name=settings.FIDO_SERVER_NAME)
|
||||
attestation= getattr(settings,'MFA_FIDO2_ATTESTATION_PREFERENCE', AttestationPreference.NONE )
|
||||
return Fido2Server(rp,attestation=attestation)
|
||||
return Fido2Server(rp)
|
||||
|
||||
|
||||
def begin_registeration(request):
|
||||
"""Starts registering a new FIDO Device, called from API"""
|
||||
server = getServer()
|
||||
from mfa import ResidentKey
|
||||
resident_key = getattr(settings,'MFA_FIDO2_RESIDENT_KEY', ResidentKey.DISCOURAGED)
|
||||
auth_attachment = getattr(settings,'MFA_FIDO2_AUTHENTICATOR_ATTACHMENT', None)
|
||||
user_verification = getattr(settings,'MFA_FIDO2_USER_VERIFICATION', None)
|
||||
registration_data, state = server.register_begin({
|
||||
u'id': request.user.username.encode("utf8"),
|
||||
u'name': (request.user.first_name + " " + request.user.last_name),
|
||||
u'displayName': request.user.username,
|
||||
}, getUserCredentials(request.user.username),user_verification = user_verification,
|
||||
resident_key_requirement = resident_key, authenticator_attachment = auth_attachment)
|
||||
}, getUserCredentials(request.user.username))
|
||||
request.session['fido_state'] = state
|
||||
|
||||
return HttpResponse(cbor.encode(registration_data), content_type = 'application/octet-stream')
|
||||
@@ -74,8 +67,6 @@ def complete_reg(request):
|
||||
uk.properties = {"device": encoded, "type": att_obj.fmt, }
|
||||
uk.owned_by_enterprise = getattr(settings, "MFA_OWNED_BY_ENTERPRISE", False)
|
||||
uk.key_type = "FIDO2"
|
||||
if auth_data.credential_data.credential_id:
|
||||
uk.user_handle = auth_data.credential_data.credential_id
|
||||
uk.save()
|
||||
if getattr(settings, 'MFA_ENFORCE_RECOVERY_METHOD', False) and not User_Keys.objects.filter(key_type = "RECOVERY", username=request.user.username).exists():
|
||||
request.session["mfa_reg"] = {"method":"FIDO2","name": getattr(settings, "MFA_RENAME_METHODS", {}).get("FIDO2", "FIDO2")}
|
||||
@@ -116,13 +107,6 @@ def auth(request):
|
||||
|
||||
def authenticate_begin(request):
|
||||
server = getServer()
|
||||
credentials=[]
|
||||
username = None
|
||||
if "base_username" in request.session:
|
||||
username = request.session["base_username"]
|
||||
if request.user.is_authenticated:
|
||||
username = request.user.username
|
||||
if username:
|
||||
credentials = getUserCredentials(request.session.get("base_username", request.user.username))
|
||||
auth_data, state = server.authenticate_begin(credentials)
|
||||
request.session['fido_state'] = state
|
||||
@@ -133,22 +117,11 @@ def authenticate_begin(request):
|
||||
def authenticate_complete(request):
|
||||
try:
|
||||
credentials = []
|
||||
username = None
|
||||
keys = None
|
||||
if "base_username" in request.session:
|
||||
username = request.session["base_username"]
|
||||
if request.user.is_authenticated:
|
||||
username = request.user.username
|
||||
username = request.session.get("base_username", request.user.username)
|
||||
server = getServer()
|
||||
credentials = getUserCredentials(username)
|
||||
data = cbor.decode(request.body)
|
||||
credential_id = data['credentialId']
|
||||
if credential_id and username is None:
|
||||
keys = User_Keys.objects.filter(user_handle = credential_id)
|
||||
if keys.exists():
|
||||
credentials=[AttestedCredentialData(websafe_decode(keys[0].properties["device"]))]
|
||||
else:
|
||||
credentials = getUserCredentials(username)
|
||||
|
||||
client_data = CollectedClientData(data['clientDataJSON'])
|
||||
auth_data = AuthenticatorData(data['authenticatorData'])
|
||||
signature = data['signature']
|
||||
@@ -182,7 +155,6 @@ def authenticate_complete(request):
|
||||
content_type = "application/json")
|
||||
else:
|
||||
import random
|
||||
if keys is None:
|
||||
keys = User_Keys.objects.filter(username = username, key_type = "FIDO2", enabled = 1)
|
||||
for k in keys:
|
||||
if AttestedCredentialData(websafe_decode(k.properties["device"])).credential_id == cred.credential_id:
|
||||
@@ -198,7 +170,7 @@ def authenticate_complete(request):
|
||||
except:
|
||||
authenticated = request.user.is_authenticated()
|
||||
if not authenticated:
|
||||
res = login(request,k.username)
|
||||
res = login(request)
|
||||
if not "location" in res: return reset_cookie(request)
|
||||
return HttpResponse(simplejson.dumps({'status': "OK", "redirect": res["location"]}),
|
||||
content_type = "application/json")
|
||||
|
||||
@@ -7,10 +7,11 @@ from django.template.context_processors import csrf
|
||||
from .models import *
|
||||
import user_agents
|
||||
from django.utils import timezone
|
||||
from django.urls import reverse
|
||||
|
||||
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
|
||||
x=''.join(random.choice(chars) for _ in range(size))
|
||||
if not User_Keys.objects.filter(properties__shas="$.key="+x).exists(): return x
|
||||
if not User_Keys.objects.filter(properties__icontains='"key": "%s"'%x).exists(): return x
|
||||
else: return id_generator(size,chars)
|
||||
|
||||
def getUserAgent(request):
|
||||
@@ -57,12 +58,13 @@ def getCookie(request):
|
||||
def add(request):
|
||||
context=csrf(request)
|
||||
if request.method=="GET":
|
||||
context.update({"username":request.GET.get('u',''),"key":request.GET.get('k','')})
|
||||
return render(request,"TrustedDevices/Add.html",context)
|
||||
else:
|
||||
key=request.POST["key"].replace("-","").replace(" ","").upper()
|
||||
context["username"] = request.POST["username"]
|
||||
context["key"] = request.POST["key"]
|
||||
trusted_keys=User_Keys.objects.filter(username=request.POST["username"],properties__has="$.key="+key)
|
||||
trusted_keys=User_Keys.objects.filter(username=request.POST["username"],properties__icontains='"key": "%s"'%key)
|
||||
cookie=False
|
||||
if trusted_keys.exists():
|
||||
tk=trusted_keys[0]
|
||||
@@ -97,7 +99,7 @@ def start(request):
|
||||
request.session["td_id"]=td.id
|
||||
try:
|
||||
if td==None: td=User_Keys.objects.get(id=request.session["td_id"])
|
||||
context={"key":td.properties["key"]}
|
||||
context={"key":td.properties["key"],"url":request.scheme+"://"+request.get_host() + reverse('add_trusted_device')}
|
||||
except:
|
||||
del request.session["td_id"]
|
||||
return start(request)
|
||||
@@ -124,12 +126,14 @@ def verify(request):
|
||||
json= jwt.decode(request.COOKIES.get('deviceid'),settings.SECRET_KEY)
|
||||
if json["username"].lower()== request.session['base_username'].lower():
|
||||
try:
|
||||
uk = User_Keys.objects.get(username=request.POST["username"].lower(), properties__has="$.key=" + json["key"])
|
||||
uk = User_Keys.objects.get(username=request.POST["username"].lower(), properties__icontains='"key": "%s"'%json["key"])
|
||||
if uk.enabled and uk.properties["status"] == "trusted":
|
||||
uk.last_used=timezone.now()
|
||||
uk.save()
|
||||
request.session["mfa"] = {"verified": True, "method": "Trusted Device","id":uk.id}
|
||||
return True
|
||||
except:
|
||||
import traceback
|
||||
print(traceback.format_exc())
|
||||
return False
|
||||
return False
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
__version__="2.7.1"
|
||||
from fido2.webauthn import ResidentKeyRequirement as ResidentKey
|
||||
from fido2.webauthn import AuthenticatorAttachment as Attachment
|
||||
from fido2.webauthn import UserVerificationRequirement as UserVerification
|
||||
from fido2.webauthn import AttestationConveyancePreference as AttestationPreference
|
||||
__version__="2.2.0"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.apps import AppConfig
|
||||
class myAppNameConfig(AppConfig):
|
||||
name = 'mfa'
|
||||
verbose_name = 'A Much Better Name'
|
||||
verbose_name = 'Django MFA2'
|
||||
@@ -2,7 +2,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import jsonfield.fields
|
||||
try:
|
||||
from django.db.models import JSONField
|
||||
except ImportError:
|
||||
try:
|
||||
from jsonfield.fields import JSONField
|
||||
except ImportError:
|
||||
raise ImportError("Can't find a JSONField implementation, please install jsonfield if django < 4.0")
|
||||
|
||||
|
||||
|
||||
def modify_json(apps, schema_editor):
|
||||
@@ -24,7 +31,7 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='user_keys',
|
||||
name='properties',
|
||||
field=jsonfield.fields.JSONField(null=True),
|
||||
field=JSONField(null=True),
|
||||
),
|
||||
migrations.RunPython(modify_json)
|
||||
]
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# Generated by Django 2.2 on 2022-10-16 14:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mfa', '0011_auto_20210530_0622'),
|
||||
]
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user_keys',
|
||||
name='user_handle',
|
||||
field=models.CharField(blank=True, default=None, max_length=255, null=True),
|
||||
),
|
||||
]
|
||||
@@ -1,5 +1,12 @@
|
||||
from django.db import models
|
||||
from jsonfield import JSONField
|
||||
try:
|
||||
from django.db.models import JSONField
|
||||
except ModuleNotFoundError:
|
||||
try:
|
||||
from jsonfield import JSONField
|
||||
except ModuleNotFoundError:
|
||||
raise ModuleNotFoundError("Can't find a JSONField implementation, please install jsonfield if django < 4.0")
|
||||
|
||||
from jose import jwt
|
||||
from django.conf import settings
|
||||
#from jsonLookup import shasLookup, hasLookup
|
||||
@@ -16,7 +23,6 @@ class User_Keys(models.Model):
|
||||
expires=models.DateTimeField(null=True,default=None,blank=True)
|
||||
last_used=models.DateTimeField(null=True,default=None,blank=True)
|
||||
owned_by_enterprise=models.BooleanField(default=None,null=True,blank=True)
|
||||
user_handle = models.CharField(default = None, null = True, blank = True, max_length = 255)
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
if self.key_type == "Trusted Device" and self.properties.get("signature","") == "":
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
throw new Error('Error getting registration data!');
|
||||
}).then(CBOR.decode).then(function(options) {
|
||||
//options.publicKey.attestation="direct"
|
||||
options.publicKey.attestation="direct"
|
||||
console.log(options)
|
||||
|
||||
return navigator.credentials.create(options);
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
{% load static %}
|
||||
<script type="application/javascript" src="{% static 'mfa/js/cbor.js' %}"></script>
|
||||
<script type="application/javascript" src="{% static 'mfa/js/ua-parser.min.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
function authen()
|
||||
{
|
||||
fetch('{% url 'fido2_begin_auth' %}', {
|
||||
method: 'GET',
|
||||
}).then(function(response) {
|
||||
if(response.ok) return response.arrayBuffer();
|
||||
throw new Error('No credential available to authenticate!');
|
||||
}).then(CBOR.decode).then(function(options) {
|
||||
console.log(options)
|
||||
return navigator.credentials.get(options);
|
||||
}).then(function(assertion) {
|
||||
res=CBOR.encode({
|
||||
"credentialId": new Uint8Array(assertion.rawId),
|
||||
"authenticatorData": new Uint8Array(assertion.response.authenticatorData),
|
||||
"clientDataJSON": new Uint8Array(assertion.response.clientDataJSON),
|
||||
"signature": new Uint8Array(assertion.response.signature)
|
||||
});
|
||||
|
||||
return fetch('{% url 'fido2_complete_auth' %}', {
|
||||
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/cbor'},
|
||||
body:res,
|
||||
|
||||
}).then(function (response) {if (response.ok) return res = response.json()}).then(function (res) {
|
||||
if (res.status=="OK")
|
||||
{
|
||||
$("#msgdiv").addClass("alert alert-success").removeClass("alert-danger")
|
||||
$("#msgdiv").html("Verified....please wait")
|
||||
{% if mode == "auth" or mode == None %}
|
||||
window.location.href=res.redirect;
|
||||
{% elif mode == "recheck" %}
|
||||
mfa_success_function();
|
||||
{% endif %}
|
||||
}
|
||||
else {
|
||||
$("#msgdiv").addClass("alert alert-danger").removeClass("alert-success")
|
||||
$("#msgdiv").html("Verification Failed as " + res.message + ", <a href='javascript:void(0)' onclick='authen())'> try again</a> or <a href='javascript:void(0)' onclick='history.back()'> Go Back</a>")
|
||||
|
||||
{% if mode == "auth" %}
|
||||
|
||||
{% elif mode == "recheck" %}
|
||||
|
||||
mfa_failed_function();
|
||||
{% endif %}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
$(document).ready(function () {
|
||||
if (location.protocol != 'https:') {
|
||||
$("#main_paragraph").addClass("alert alert-danger")
|
||||
$("#main_paragraph").html("FIDO2 must work under secure context")
|
||||
} else {
|
||||
ua=new UAParser().getResult()
|
||||
if (ua.browser.name == "Safari" || ua.browser.name == "Mobile Safari" || ua.os.name == "iOS" || ua.os.name == "iPadOS")
|
||||
$("#res").html("<button class='btn btn-success' onclick='authen()'>Authenticate...</button>")
|
||||
else
|
||||
authen()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@@ -1,4 +1,6 @@
|
||||
{% load static %}
|
||||
<script type="application/javascript" src="{% static 'mfa/js/cbor.js' %}"></script>
|
||||
<script type="application/javascript" src="{% static 'mfa/js/ua-parser.min.js' %}"></script>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-10 col-sm-offset-1 col-xs-12 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2 offset-2 col-8">
|
||||
@@ -45,4 +47,71 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 'FIDO2/Auth_JS.html' %}
|
||||
<script type="text/javascript">
|
||||
function authen()
|
||||
{
|
||||
fetch('{% url 'fido2_begin_auth' %}', {
|
||||
method: 'GET',
|
||||
}).then(function(response) {
|
||||
if(response.ok) return response.arrayBuffer();
|
||||
throw new Error('No credential available to authenticate!');
|
||||
}).then(CBOR.decode).then(function(options) {
|
||||
console.log(options)
|
||||
return navigator.credentials.get(options);
|
||||
}).then(function(assertion) {
|
||||
res=CBOR.encode({
|
||||
"credentialId": new Uint8Array(assertion.rawId),
|
||||
"authenticatorData": new Uint8Array(assertion.response.authenticatorData),
|
||||
"clientDataJSON": new Uint8Array(assertion.response.clientDataJSON),
|
||||
"signature": new Uint8Array(assertion.response.signature)
|
||||
});
|
||||
|
||||
return fetch('{% url 'fido2_complete_auth' %}', {
|
||||
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/cbor'},
|
||||
body:res,
|
||||
|
||||
}).then(function (response) {if (response.ok) return res = response.json()}).then(function (res) {
|
||||
if (res.status=="OK")
|
||||
{
|
||||
$("#msgdiv").addClass("alert alert-success").removeClass("alert-danger")
|
||||
$("#msgdiv").html("Verified....please wait")
|
||||
{% if mode == "auth" %}
|
||||
window.location.href=res.redirect;
|
||||
{% elif mode == "recheck" %}
|
||||
mfa_success_function();
|
||||
{% endif %}
|
||||
}
|
||||
else {
|
||||
$("#msgdiv").addClass("alert alert-danger").removeClass("alert-success")
|
||||
$("#msgdiv").html("Verification Failed as " + res.message + ", <a href='javascript:void(0)' onclick='authen())'> try again</a> or <a href='javascript:void(0)' onclick='history.back()'> Go Back</a>")
|
||||
|
||||
{% if mode == "auth" %}
|
||||
|
||||
{% elif mode == "recheck" %}
|
||||
|
||||
mfa_failed_function();
|
||||
{% endif %}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
$(document).ready(function () {
|
||||
if (location.protocol != 'https:') {
|
||||
$("#main_paragraph").addClass("alert alert-danger")
|
||||
$("#main_paragraph").html("FIDO2 must work under secure context")
|
||||
} else {
|
||||
ua=new UAParser().getResult()
|
||||
if (ua.browser.name == "Safari" || ua.browser.name == "Mobile Safari" || ua.os.name == "iOS" || ua.os.name == "iPadOS")
|
||||
$("#res").html("<button class='btn btn-success' onclick='authen()'>Authenticate...</button>")
|
||||
else
|
||||
authen()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<tr><td colspan="7" align="center">You didn't have any keys yet.</td> </tr>
|
||||
<tr><td colspan="7" align="center">You don't have any keys yet.</td> </tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% block head %}
|
||||
<script src="{% static 'mfa/js/qrious.min.js' %}" type="text/javascript"></script>
|
||||
<style>
|
||||
#two-factor-steps {
|
||||
border: 1px solid #ccc;
|
||||
@@ -12,6 +14,12 @@
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function (){
|
||||
var qr = new QRious({
|
||||
element: document.getElementById('qr'),
|
||||
value: "{{ url }}?u={{ request.user.username }}&k={{ key }}"
|
||||
});
|
||||
})
|
||||
function sendEmail() {
|
||||
$("#modal-title").html("Send Link")
|
||||
$("#modal-body").html("Sending Email, Please wait....");
|
||||
@@ -82,21 +90,52 @@
|
||||
{% if not_allowed %}
|
||||
<div class="alert alert-danger">You can't add any more devices, you need to remove previously trusted devices first.</div>
|
||||
{% else %}
|
||||
<p style="color: green">Allow access from mobile phone and tables.</p>
|
||||
<p style="color: green">Allow access from mobile phone and tables.</p><br/>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h5>Steps:</h5>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h5>Using Camera</h5>
|
||||
<ol>
|
||||
<li>Using your mobile/table, open Chrome/Firefox.</li>
|
||||
<li>Go to <b>{{ HOST }}{{ BASE_URL }}devices/add</b> <a href="javascript:void(0)" onclick="sendEmail()" title="Send to my email"><i class="fas fa-paper-plane"></i></a></li>
|
||||
<li>Scan the following barcode <br/>
|
||||
<img id="qr"/> <br/>
|
||||
</li>
|
||||
<li>Confirm the consent and submit form.</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
<h5>Manual</h5>
|
||||
<ol>
|
||||
<li>Using your mobile/table, open Chrome/Firefox.</li>
|
||||
<li>Go to <b>{{ url }}</b> </li>
|
||||
<li>Enter your username & following 6 digits<br/>
|
||||
<span style="font-size: 16px;font-weight: bold; margin-left: 50px">{{ key|slice:":3" }} - {{ key|slice:"3:" }}</span>
|
||||
</li>
|
||||
<li>This window will ask to confirm the device.</li>
|
||||
<li>Confirm the consent and submit form.</li>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8 offset-2">
|
||||
This window will ask to confirm the device.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</ol>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
{% include "modal.html" %}
|
||||
{% include 'mfa_check.html' %}
|
||||
{% endblock %}
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -60,13 +60,11 @@ def reset_cookie(request):
|
||||
response.delete_cookie("base_username")
|
||||
return response
|
||||
|
||||
def login(request,username = None):
|
||||
def login(request):
|
||||
from django.contrib import auth
|
||||
from django.conf import settings
|
||||
callable_func = __get_callable_function__(settings.MFA_LOGIN_CALLBACK)
|
||||
if not username:
|
||||
username = request.session["base_username"]
|
||||
return callable_func(request,username=username)
|
||||
return callable_func(request,username=request.session["base_username"])
|
||||
|
||||
|
||||
@login_required
|
||||
|
||||
109
pytest.ini
Normal file
109
pytest.ini
Normal file
@@ -0,0 +1,109 @@
|
||||
[pytest]
|
||||
# Searching
|
||||
python_files = test_*
|
||||
python_classes = Tests*
|
||||
python_functions = test_*
|
||||
|
||||
env_files =
|
||||
.env
|
||||
|
||||
# do not search for tests in these folders
|
||||
norecursedirs = .vscode .tox docs example img mfa venv .coverage django_mfa2.egg-info
|
||||
|
||||
# Add folder to PYTHONPATH
|
||||
# requires pytest >= 7.0.0
|
||||
pythonpath = .
|
||||
|
||||
|
||||
# https://pytest-django.readthedocs.io/en/latest/usage.html
|
||||
DJANGO_SETTINGS_MODULE = tests.settings
|
||||
|
||||
|
||||
# do not override the debug mode (True/False) set in the django settings module
|
||||
# https://pytest-django.readthedocs.io/en/latest/usage.html#additional-pytest-ini-settings
|
||||
django_debug_mode = keep
|
||||
|
||||
|
||||
#
|
||||
# set env variables
|
||||
# https://tech.serhatteker.com/post/2020-02/test-env-vars-in-python/
|
||||
# https://github.com/pytest-dev/pytest-env
|
||||
; env =
|
||||
; KEY=value
|
||||
|
||||
|
||||
addopts =
|
||||
# verbose
|
||||
-v
|
||||
# more verbosity
|
||||
# -vv
|
||||
# Don't show warnings
|
||||
# -p no:warnings
|
||||
# generates coverage report
|
||||
# note that enabling pytest coverage will cause debugging pytest to fail on pycharm
|
||||
# add the --no-cov to the pytest configuration on pycharm to allow for debugging pytest
|
||||
--cov=./mfa
|
||||
# surpress generating converage if one or more tests failed
|
||||
; --no-cov-on-fail
|
||||
# do not run migrations => faster test initialization
|
||||
# --nomigrations
|
||||
# Show hypthesis statistics whereever hypothesis was used
|
||||
# ignore these tests/files when looking for tests
|
||||
#--ignore=
|
||||
# black
|
||||
# --black
|
||||
--hypothesis-show-statistics
|
||||
# Add --reuse-db if you want to speed up tests by reusing the database between test runs.
|
||||
#--reuse-db
|
||||
|
||||
|
||||
# Define additional pytest markers so that using them in test will not trigger warnings
|
||||
# To show the help line use: % pytest --marker
|
||||
# To run pytest on a specifc marker use: pytest -m mark
|
||||
# to run pytestt on several markers use quotation and logic operators as in:
|
||||
# pytest -m "mark1 and mark2"
|
||||
# pytest -m "mark1 or mark2"
|
||||
# pytest -m "mark1 and not mark2"
|
||||
markers =
|
||||
API: tests of server api functions whether it is exposed as REST API or otherwise
|
||||
BLACK_BOX: Black Box tests
|
||||
WHITE_BOX: White Box tests
|
||||
ENVIRONMENT: tests for the environment
|
||||
CONFIGURATION: tests related configurations
|
||||
LOGGING: tests related to logging
|
||||
UNIT: Unit tests
|
||||
INTEGRATION: Integration testing
|
||||
UTILS: tests for utilities
|
||||
FOCUS: tests under the microscope... under the spotlight... in focus
|
||||
FUNC: functional teesting
|
||||
REGRESSION: tests for fixed bugs
|
||||
|
||||
DJANGO: tests related to DJANGO
|
||||
|
||||
HTTP_REQUEST: tests of functions that handles HTTP REQUESTS
|
||||
HTTP_GET: tests of functions that handles HTTP_GET_REQUESTS
|
||||
HTTP_POST: tests of functions that handles HTTP_POST_REQUESTS
|
||||
AUTH: tests related to user authentication
|
||||
SQL_DB: tests related to the sql database
|
||||
|
||||
CLI: tests related to flask-cli
|
||||
SERVER: tests for the server
|
||||
|
||||
API_V1: API related tests
|
||||
|
||||
PRIVILEGED_USER: tests for privileged users
|
||||
NON_PRIVILEGED_USER: tests for non-privileged users
|
||||
PERMISSIONS: tests related to permissions
|
||||
|
||||
ANNONYMOUS_USER: tests for non-authenticated users
|
||||
AUTHENTICATED_USER: tests for authenticated users
|
||||
|
||||
ENDPOINTS: tests for endpoints (API nodes)
|
||||
SERIALIZERS: tests for serializers
|
||||
VIEWS: tests for DRF viewsets
|
||||
FILTERS: tests for DRF filters
|
||||
MODELS: tests for models
|
||||
VALIDATORS: tests for validators
|
||||
|
||||
ERROR_HANDLING: tests for error handling
|
||||
SECURITY: tests for security
|
||||
@@ -6,5 +6,5 @@ python-u2flib-server
|
||||
ua-parser
|
||||
user-agents
|
||||
python-jose
|
||||
fido2 == 1.0.0
|
||||
fido2==1.1.2
|
||||
jsonLookup
|
||||
|
||||
10
requirements_testing.txt
Normal file
10
requirements_testing.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
tox
|
||||
pytest>=7.0.0
|
||||
pytest-xdist
|
||||
pytest-cov # Test coverage
|
||||
pytest-dotenv # plugin to load environment from .env file
|
||||
pytest-env # plugin to allow passing environment variable to pytest environmentt
|
||||
pytest-mock # plugin that provides a mocker fixture which is a thin-wrapper around the patching API provided by the mock package
|
||||
hypothesis # plugin that helps in automatize generating random values instead of static values in pyttests
|
||||
pytest-django # pytest support for Django
|
||||
validators # a package containing several validator functions
|
||||
11
setup.py
11
setup.py
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
|
||||
|
||||
setup(
|
||||
name='django-mfa2',
|
||||
version='2.6.1',
|
||||
version='2.8.0',
|
||||
description='Allows user to add 2FA to their accounts',
|
||||
long_description=open("README.md").read(),
|
||||
long_description_content_type="text/markdown",
|
||||
@@ -14,24 +14,23 @@ setup(
|
||||
url = 'https://github.com/mkalioby/django-mfa2/',
|
||||
download_url='https://github.com/mkalioby/django-mfa2/',
|
||||
license='MIT',
|
||||
packages=find_packages(),
|
||||
packages=find_packages(exclude=("tests",)),
|
||||
install_requires=[
|
||||
'django >= 2.0',
|
||||
'jsonfield',
|
||||
'simplejson',
|
||||
'pyotp',
|
||||
'python-u2flib-server',
|
||||
'ua-parser',
|
||||
'user-agents',
|
||||
'python-jose',
|
||||
'fido2 == 1.0.0',
|
||||
'jsonLookup'
|
||||
'fido2 == 1.1.2',
|
||||
],
|
||||
python_requires=">=3.5",
|
||||
include_package_data=True,
|
||||
zip_safe=False, # because we're including static files
|
||||
classifiers=[
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
#"Development Status :: 4 - Beta",
|
||||
"Environment :: Web Environment",
|
||||
"Framework :: Django",
|
||||
"Framework :: Django :: 2.0",
|
||||
@@ -41,6 +40,7 @@ setup(
|
||||
"Framework :: Django :: 3.1",
|
||||
"Framework :: Django :: 3.2",
|
||||
"Framework :: Django :: 4.0",
|
||||
"Framework :: Django :: 4.1",
|
||||
"Intended Audience :: Developers",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
@@ -51,6 +51,7 @@ setup(
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
)
|
||||
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
19
tests/conftest.py
Normal file
19
tests/conftest.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
# @pytest.fixture
|
||||
# def api_request(rf):
|
||||
# request = rf.get('/url')
|
||||
# # Modify the request object as needed (e.g., set user, add data)
|
||||
# return request
|
||||
|
||||
# @pytest.fixture
|
||||
# def create_test_model(db):
|
||||
# def make_model(**kwargs):
|
||||
# return MyModel.objects.create(**kwargs)
|
||||
# return make_model
|
||||
|
||||
@pytest.fixture
|
||||
def authenticated_user(client, django_user_model):
|
||||
user = django_user_model.objects.create_user(username='test', password='123')
|
||||
client.login(username='test', password='123')
|
||||
return user
|
||||
51
tests/settings.py
Normal file
51
tests/settings.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import os
|
||||
|
||||
|
||||
SECRET_KEY = 'fake-key-for-testing'
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'mfa'
|
||||
]
|
||||
ROOT_URLCONF="mfa.urls"
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': ':memory:',
|
||||
}
|
||||
}
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [
|
||||
os.path.join(BASE_DIR ,'mfa','templates' ),
|
||||
os.path.join(BASE_DIR ,'tests','templates' )
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
MFA_UNALLOWED_METHODS = []
|
||||
11
tests/templates/base.html
Normal file
11
tests/templates/base.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{% block head %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
29
tests/test_views.py
Normal file
29
tests/test_views.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
from django.urls import reverse
|
||||
|
||||
@pytest.mark.VIEWS
|
||||
@pytest.mark.DJANGO
|
||||
@pytest.mark.ANNONYMOUS_USER
|
||||
@pytest.mark.django_db
|
||||
def test_index_unauthenticated(client):
|
||||
url = reverse("mfa_home")
|
||||
response = client.get(url)
|
||||
assert response is not None
|
||||
assert response.status_code == 302
|
||||
assert response.url=="/accounts/login/?next=/"
|
||||
|
||||
@pytest.mark.VIEWS
|
||||
@pytest.mark.AUTHENTICATED_USER
|
||||
@pytest.mark.django_db
|
||||
def test_index_authenticated(client, authenticated_user):
|
||||
url = reverse("mfa_home")
|
||||
response = client.get(url)
|
||||
assert response is not None
|
||||
assert response.status_code == 200
|
||||
assert isinstance(response.templates, list)
|
||||
assert len(response.templates) == 4
|
||||
for template in response.templates:
|
||||
assert template.name in ["modal.html", "base.html", "mfa_base.html", "MFA.html"]
|
||||
|
||||
|
||||
|
||||
52
tox.ini
Normal file
52
tox.ini
Normal file
@@ -0,0 +1,52 @@
|
||||
# Tox (https://tox.readthedocs.io/) is a tool for running tests
|
||||
# in multiple virtualenvs. This configuration file will run the
|
||||
# test suite on all supported python versions. To use it, "pip install tox"
|
||||
# and then run "tox" from this directory.
|
||||
#
|
||||
# See also https://tox.readthedocs.io/en/latest/config.html for more
|
||||
# configuration options.
|
||||
|
||||
[tox]
|
||||
# Choose your Python versions. They have to be available
|
||||
# on the system the tests are run on.
|
||||
# comma separated
|
||||
envlist =
|
||||
python{3.6,3.7,3.8,3.9}-django2.2
|
||||
python{3.6,3.7,3.8,3.9}-django3
|
||||
python{3.8,3.9,3.10,3.11}-django4
|
||||
python{3.8,3.9,3.10,3.11}-django5
|
||||
|
||||
# Tell tox to not require a setup.py file
|
||||
;skipsdist = True
|
||||
|
||||
isolated_build = True
|
||||
|
||||
[testenv]
|
||||
# https://tox.wiki/en/latest/example/basic.html#using-a-different-default-pypi-url
|
||||
;setenv =
|
||||
; PIP_INDEX_URL = https://pypi.my-alternative-index.org
|
||||
|
||||
# https://tech.serhatteker.com/post/2020-02/test-env-vars-in-python/
|
||||
;setenv =
|
||||
; NAME=value
|
||||
|
||||
# https://tox.wiki/en/latest/example/basic.html#passing-down-environment-variables
|
||||
# passenv = ENV_VAR_NAME
|
||||
|
||||
# https://tox.wiki/en/latest/example/pytest.html#extended-example-change-dir-before-test-and-use-per-virtualenv-tempdir
|
||||
;changedir = tests
|
||||
|
||||
deps =
|
||||
django22: django>=2.2,<2.3
|
||||
django32: django>=3.2,<3.3
|
||||
django40: django>=4.0,<4.1
|
||||
django41: django>=4.1,<4.2
|
||||
django42: django>=4.2,<4.3
|
||||
django50: django==5.0
|
||||
-rrequirements.txt
|
||||
-rrequirements_testing.txt
|
||||
|
||||
# https://tox.wiki/en/latest/example/basic.html#ignoring-a-command-exit-code
|
||||
commands =
|
||||
; pytest --junitxml=report.xml
|
||||
pytest {posargs}
|
||||
Reference in New Issue
Block a user