From 98b9fce1d2ba7226838539238858ccb9214c18d7 Mon Sep 17 00:00:00 2001 From: Mohamed ElKalioby Date: Mon, 19 Dec 2022 14:55:37 +0300 Subject: [PATCH] Support for Django4.0+ JSONField --- CHANGELOG.md | 6 +++++- README.md | 12 +++++++++--- mfa/migrations/0005_auto_20181115_2014.py | 11 +++++++++-- mfa/models.py | 9 ++++++++- setup.py | 10 +++++----- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0fe16..f301507 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log -## 2.7.0 (Dev) +## 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. diff --git a/README.md b/README.md index 89fc2a8..7155490 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,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. @@ -43,8 +45,12 @@ Depends on # Installation 1. using pip - - `pip install django-mfa2` + * 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` diff --git a/mfa/migrations/0005_auto_20181115_2014.py b/mfa/migrations/0005_auto_20181115_2014.py index 8f9b76d..3f65a26 100644 --- a/mfa/migrations/0005_auto_20181115_2014.py +++ b/mfa/migrations/0005_auto_20181115_2014.py @@ -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) ] diff --git a/mfa/models.py b/mfa/models.py index d4eff59..9d0ac12 100644 --- a/mfa/models.py +++ b/mfa/models.py @@ -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 diff --git a/setup.py b/setup.py index a56f597..19822e9 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import find_packages, setup setup( name='django-mfa2', - version='2.7.0RC1', + 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", @@ -17,7 +17,6 @@ setup( packages=find_packages(), install_requires=[ 'django >= 2.0', - 'jsonfield', 'simplejson', 'pyotp', 'python-u2flib-server', @@ -25,14 +24,13 @@ setup( 'user-agents', 'python-jose', 'fido2 == 1.0.0', - 'jsonLookup' ], 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", + "Development Status :: 5 - Production/Stable", + #"Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 2.0", @@ -42,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", @@ -52,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", ] )