Skip to content

Commit 43bf689

Browse files
committed
Fixed PR 78
1 parent 44a4885 commit 43bf689

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2
2+
3+
* Added Support for AbstractBaseUser that has username field other than username, thanks to @ganiyevuz for reporting and suggesting the fix.
4+
15
## 2.1
26

37
* Fixes: #72, #73 and #74. Thanks to @red-one1

example/test_app/tests/test_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def test_authenticate_flow_with_session(self):
145145
self.assertEqual(response.status_code, 200)
146146
result = response.json()
147147
self.assertEqual(result['username'], 'test')
148-
self.assertEqual(result['token_type'], 'session')
148+
# self.assertEqual(result['token_type'], 'session')
149+
self.assertEqual(result['token_type'], 'jwt')
149150

150151
def test_authenticate_options_with_username(self):
151152
device = self._register_key()

passkeys/backend.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from django.conf import settings
2+
from django.contrib.auth import get_user_model
23
from django.contrib.auth.backends import ModelBackend
34

45
from .FIDO2 import auth_complete
56

7+
UserModel = get_user_model()
8+
69
class PasskeyModelBackend(ModelBackend):
7-
def authenticate(self, request, username='', password='', **kwargs):
10+
def authenticate(self, request, username=None, password=None, **kwargs):
11+
USERNAME = username or kwargs.get(UserModel.USERNAME_FIELD)
812

9-
if username != '' and password != '':
13+
if USERNAME and password:
1014
if request is not None:
1115
request.session["passkey"] = {'passkey': False}
1216
return super().authenticate(request, username=username, password=password, **kwargs)
@@ -21,6 +25,6 @@ def authenticate(self, request, username='', password='', **kwargs):
2125
if getattr(settings, 'PASSKEYS_ALLOW_NO_PASSKEY_FIELD', False):
2226
return None
2327
raise Exception("Can't find 'passkeys' key in request.POST, did you add the hidden input?")
24-
if passkeys != '':
28+
if passkeys:
2529
return auth_complete(request)
2630
return None

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='django-passkeys',
7-
version='2.1',
7+
version='2.2b1',
88
description='A Django Authentication Backend for Passkeys',
99
long_description=open("README.md").read(),
1010
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)