Skip to content

Commit

Permalink
v1.27b1
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalioby committed Oct 31, 2023
1 parent ac02b78 commit a50a6a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.7

* Fix: issue if the user isn't defined by username field #25.

## v1.2.6

* Adding Django 5.0 to test matrix and pypi classifiers
Expand Down
10 changes: 7 additions & 3 deletions passkeys/FIDO2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import fido2.features
from django.conf import settings
from django.contrib.auth import get_user_model
from django.http import JsonResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
Expand All @@ -22,7 +23,10 @@ def enable_json_mapping():


def getUserCredentials(user):
return [AttestedCredentialData(websafe_decode(uk.token)) for uk in UserPasskey.objects.filter(user__username = user)]
User = get_user_model()
username_field = User.USERNAME_FIELD
filter_args = {"user__"+username_field : user}
return [AttestedCredentialData(websafe_decode(uk.token)) for uk in UserPasskey.objects.filter(**filter_args)]


def getServer(request=None):
Expand Down Expand Up @@ -61,8 +65,8 @@ def reg_begin(request):
auth_attachment = getattr(settings,'KEY_ATTACHMENT', None)
registration_data, state = server.register_begin({
u'id': urlsafe_b64encode(request.user.username.encode("utf8")),
u'name': request.user.username,
u'displayName': request.user.username,
u'name': request.user.get_username(),
u'displayName': request.user.get_full_name()
}, getUserCredentials(request.user), authenticator_attachment = auth_attachment, resident_key_requirement=fido2.webauthn.ResidentKeyRequirement.PREFERRED)
request.session['fido2_state'] = state
return JsonResponse(dict(registration_data))
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='django-passkeys',
version='1.2.6',
version='1.2.7b1',
description='A Django Authentication Backend for Passkeys',
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand All @@ -24,8 +24,8 @@
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",
Expand Down

0 comments on commit a50a6a1

Please sign in to comment.