Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token delete formdata fix method #53

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f7d06c2
Token delete formdata fix method
AndreasDickow Aug 25, 2021
392b9ef
init internationalization and csp save templates
AndreasDickow Oct 6, 2021
7f2b9a3
fixing csp attributes and translations
AndreasDickow Mar 8, 2022
34510dd
TrustedDevices - start: Minor fixes
jmbizfac Mar 8, 2022
98982ce
Inline Styles removed from all subfiles in template folder
jmbizfac Mar 8, 2022
2c4a48d
Stylesheet imported for respective files
jmbizfac Mar 8, 2022
3e4e62a
javascript exported in own file
jmbizfac Mar 8, 2022
2d8cd96
EMAIL recheck onlicks removed
jmbizfac Mar 8, 2022
fb25e34
TOTP Add.html free of onclick events
jmbizfac Mar 11, 2022
9ec9708
All files checked for inline js
jmbizfac Mar 11, 2022
1057987
final adjustments
jmbizfac Mar 11, 2022
9152b6d
translation tags in templates
AndreasDickow Mar 19, 2022
8fe6575
code cleanup
AndreasDickow Mar 19, 2022
1800ff9
code cleanup
AndreasDickow Mar 29, 2022
9c5bda9
todo test redirect html code
AndreasDickow Mar 29, 2022
c99c697
template substitutions
AndreasDickow Mar 30, 2022
a5803d3
fix attestation privacy warning
AndreasDickow Jun 2, 2022
df2c10f
Update requirements.txt
AndreasDickow Jun 8, 2022
5b4fb11
Update setup.py
AndreasDickow Jun 8, 2022
7715b32
Update requirements.txt
AndreasDickow Jun 8, 2022
7ce386d
Update setup.py
AndreasDickow Jun 8, 2022
547c86b
Update setup.py
AndreasDickow Jun 8, 2022
d008981
Update requirements.txt
AndreasDickow Jun 8, 2022
8d75755
Update recheck.js
AndreasDickow Jun 9, 2022
1f67349
Update FIDO2.py
AndreasDickow Jun 30, 2022
419f66b
Update add.js
AndreasDickow Jun 30, 2022
92c4f02
Update setup.py
AndreasDickow Jul 4, 2022
bc4396d
Update __init__.py
AndreasDickow Jul 4, 2022
b273286
Update recheck.js
AndreasDickow Jul 5, 2022
ce0686c
Update setup.py
AndreasDickow Jul 5, 2022
9948002
Token delete formdata fix method
AndreasDickow Aug 25, 2021
35ac10c
update merge
AndreasDickow Jul 7, 2022
6ca0895
update merge
AndreasDickow Jul 7, 2022
738c8ee
update fido auth
AndreasDickow Jul 7, 2022
eb5b4d1
Update FIDO2.py
AndreasDickow Jul 7, 2022
ad063bd
update fido auth
AndreasDickow Jul 7, 2022
b7bcf35
update fido auth
AndreasDickow Jul 7, 2022
d0af4b5
update fido auth
AndreasDickow Jul 7, 2022
d400918
update fido auth
AndreasDickow Jul 7, 2022
b325ce3
update fido auth
AndreasDickow Jul 7, 2022
ff4e987
internationalization: german texts
AndreasDickow Jul 7, 2022
0db200f
internationalization: german texts
AndreasDickow Jul 7, 2022
c7cb057
internationalization: german texts
AndreasDickow Jul 7, 2022
aaf072b
internationalization: german texts
AndreasDickow Jul 7, 2022
3002d18
internationalization: german texts
AndreasDickow Jul 7, 2022
6b354b8
internationalization: german texts
AndreasDickow Jul 7, 2022
82ef89c
hide account details from attestation
AndreasDickow Jul 14, 2022
5caccca
remove unneccesary attestation
AndreasDickow Jul 20, 2022
fd78e54
fix CVE-2022-42731
AndreasDickow May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ coverage.xml
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
recursive-include mfa/templates *
recursive-include mfa/static *
recursive-include mfa/static *
recursive-include mfa/locale *
Binary file added mfa/.DS_Store
Binary file not shown.
8 changes: 5 additions & 3 deletions mfa/FIDO2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import datetime
from .Common import get_redirect_url
from django.utils import timezone

from django.http import JsonResponse

def recheck(request):
"""Starts FIDO2 recheck"""
Expand Down Expand Up @@ -49,13 +49,15 @@ def begin_registeration(request):
def complete_reg(request):
"""Completes the registeration, called by API"""
try:
if not "fido_state" in request.session:
return JsonResponse({'status': 'ERR', "message": "FIDO Status can't be found, please try again"})
data = cbor.decode(request.body)

client_data = CollectedClientData(data['clientDataJSON'])
att_obj = AttestationObject((data['attestationObject']))
server = getServer()
auth_data = server.register_complete(
request.session['fido_state'],
request.session.pop['fido_state'],
client_data,
att_obj
)
Expand All @@ -75,7 +77,7 @@ def complete_reg(request):
client.captureException()
except:
pass
return HttpResponse(simplejson.dumps({'status': 'ERR', "message": "Error on server, please try again later"}))
return JsonResponse({'status': 'ERR', "message": "Error on server, please try again later"})


def start(request):
Expand Down
17 changes: 9 additions & 8 deletions mfa/TrustedDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import random
from django.shortcuts import render
from django.http import HttpResponse
from django.template.context import RequestContext
from django.utils.translation import gettext
from django.template.context_processors import csrf
from .models import *
import user_agents
from django.utils import timezone
from django.utils.translation import gettext

def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
x=''.join(random.choice(chars) for _ in range(size))
Expand All @@ -28,7 +29,7 @@ def trust_device(request):
tk.properties["status"]="trusted"
tk.save()
del request.session["td_id"]
return HttpResponse("OK")
return HttpResponse(gettext("OK"))

def checkTrusted(request):
res = ""
Expand Down Expand Up @@ -70,7 +71,7 @@ def add(request):
ua=request.META['HTTP_USER_AGENT']
agent=user_agents.parse(ua)
if agent.is_pc:
context["invalid"]="This is a PC, it can't used as a trusted device."
context["invalid"]=gettext("This is a PC, it can't used as a trusted device.")
else:
tk.properties["user_agent"]=ua
tk.save()
Expand All @@ -80,7 +81,7 @@ def add(request):
# context["success"]=True

else:
context["invalid"]="The username or key is wrong, please check and try again."
context["invalid"]=gettext("The username or key is wrong, please check and try again.")

return render(request,"TrustedDevices/Add.html", context)

Expand Down Expand Up @@ -110,11 +111,11 @@ def send_email(request):
if e=="":
e=request.session.get("user",{}).get("email","")
if e=="":
res = "User has no email on the system."
elif send([e],"Add Trusted Device Link",body):
res="Sent Successfully"
res = gettext("User has no email on the system.")
elif send([e],gettext("Add Trusted Device Link"),body):
res=gettext("Sent Successfully")
else:
res="Error occured, please try again later."
res=gettext("Error occured, please try again later.")
return HttpResponse(res)


Expand Down
7 changes: 4 additions & 3 deletions mfa/U2F.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from django.template.context_processors import csrf
from django.conf import settings
from django.http import HttpResponse
from django.utils.translation import gettext
from .models import *
from .views import login
from .Common import get_redirect_url
import datetime
from django.utils import timezone
from django.utils.translation import gettext

def recheck(request):
context = csrf(request)
Expand All @@ -37,7 +38,7 @@ def check_errors(request, data):
if "errorCode" in data:
if data["errorCode"] == 0: return True
if data["errorCode"] == 4:
return HttpResponse("Invalid Security Key")
return HttpResponse(gettext("Invalid Security Key"))
if data["errorCode"] == 1:
return auth(request)
return True
Expand Down Expand Up @@ -90,7 +91,7 @@ def bind(request):
cert_hash=hashlib.md5(cert.public_bytes(Encoding.PEM)).hexdigest()
q=User_Keys.objects.filter(key_type="U2F", properties__icontains= cert_hash)
if q.exists():
return HttpResponse("This key is registered before, it can't be registered again.")
return HttpResponse(gettext("This key is registered before, it can't be registered again."))
User_Keys.objects.filter(username=request.user.username,key_type="U2F").delete()
uk = User_Keys()
uk.username = request.user.username
Expand Down
2 changes: 1 addition & 1 deletion mfa/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="2.2.0"
__version__="2.4.1"
3 changes: 1 addition & 2 deletions mfa/helpers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pyotp
from .models import *
from . import TrustedDevice, U2F, FIDO2, totp
import simplejson
from django.shortcuts import HttpResponse
from mfa.views import verify,goto
from mfa.views import verify
def has_mfa(request,username):
if User_Keys.objects.filter(username=username,enabled=1).count()>0:
return verify(request, username)
Expand Down
Binary file added mfa/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
Loading