Finalzed Python 3 Support

This commit is contained in:
Mohamed ElKalioby
2019-01-23 15:34:47 +03:00
parent 6efd643022
commit 7efd3ccc38
10 changed files with 35 additions and 11 deletions

View File

@@ -77,7 +77,7 @@ Depends on
import mfa.TrustedDevice
urls_patterns= [
'...',
url(r'^mfa/', include(mfa.urls)),
url(r'^mfa/', include('mfa.urls')),
url(r'devices/add$', mfa.TrustedDevice.add,name="mfa_add_new_trusted_device"), # This short link to add new trusted device
'....',
]

View File

@@ -12,7 +12,7 @@ from django.conf import settings
from .models import *
from fido2.utils import websafe_decode,websafe_encode
from fido2.ctap2 import AttestedCredentialData
from views import login
from .views import login
import datetime
from django.utils import timezone

View File

@@ -1 +1,10 @@
from . import urls
# @property
# def urls():
# import django
# if django.VERSION < (1, 9):
# from .mfa_urls import url_patterns
# return url_patterns, 'mfa', ''
# else:
# from .mfa_urls import url_patterns
# return url_patterns,'mfa'
#

4
mfa/apps.py Normal file
View File

@@ -0,0 +1,4 @@
from django.apps import AppConfig
class myAppNameConfig(AppConfig):
name = 'mfa'
verbose_name = 'A Much Better Name'

View File

@@ -5,8 +5,13 @@ from django.db import models, migrations
import jsonfield.fields
class Migration(migrations.Migration):
def modify_json(apps, schema_editor):
from django.conf import settings
if "mysql" in settings.DATABASES.get("default", {}).get("engine", ""):
migrations.RunSQL("alter table mfa_user_keys modify column properties json;")
class Migration(migrations.Migration):
dependencies = [
('mfa', '0004_user_keys_enabled'),
]
@@ -21,5 +26,5 @@ class Migration(migrations.Migration):
name='properties',
field=jsonfield.fields.JSONField(null=True),
),
migrations.RunSQL("alter table mfa_user_keys modify column properties json;")
migrations.RunPython(modify_json)
]

View File

@@ -18,3 +18,5 @@ class User_Keys(models.Model):
self.properties["signature"]= jwt.encode({"username": self.username, "key": self.properties["key"]}, settings.SECRET_KEY)
super(User_Keys, self).save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
class Meta:
app_label='mfa'

View File

@@ -1,6 +1,7 @@
from django.conf.urls import url
from . import views,totp,U2F,TrustedDevice,helpers,FIDO2,Email
from . import views,totp,U2F,TrustedDevice,helpers,FIDO2,Email
app_name='mfa'
urlpatterns = [
url(r'totp/start/', totp.start , name="start_new_otop"),
url(r'totp/getToken', totp.getToken , name="get_new_otop"),

View File

@@ -1,6 +1,9 @@
from django.shortcuts import render,render_to_response
from django.http import HttpResponse,HttpResponseRedirect
from .models import *
try:
from django.urls import reverse
except:
from django.core.urlresolvers import reverse
from django.template.context_processors import csrf
from django.template.context import RequestContext

View File

@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
setup(
name='django-mfa2',
version='0.9.2',
version='0.9.4',
description='Allows user to add 2FA to their accounts',
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
@@ -17,7 +17,7 @@ setup(
license='MIT',
packages=find_packages(),
install_requires=[
'Django>=1.7',
'django >= 1.7',
'jsonfield',
'simplejson',
'pyotp',
@@ -25,7 +25,7 @@ setup(
'ua-parser',
'user-agents',
'python-jose',
'fido2==0.5'
'fido2 == 0.5',
'jsonLookup'
],
include_package_data=True,