mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-19 14:37:48 +00:00
chore(backend): bump allauth version (#13236)
* bump allauth version * update used api * bump api * fix call api signature * fix tests
This commit is contained in:
1 parent
d859a1a4ad
commit
6387ae95e1
7 files changed
+44
-15
No files matched your search
@@ -1,11 +1,14 @@
|
||||
"""InvenTree API version information."""
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 576
|
||||
INVENTREE_API_VERSION = 577
|
||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||
|
||||
INVENTREE_API_TEXT = """
|
||||
|
||||
v577 -> 2026-11-12 : https://github.com/inventree/InvenTree/pull/13236
|
||||
- non-function doc changes from allauth
|
||||
|
||||
v576 -> 2026-11-11 : https://github.com/inventree/InvenTree/pull/13247
|
||||
- Adds /api/system/messages/ endpoint: staff-only, read-only; classified system messages are provided in the "messages" array
|
||||
|
||||
|
||||
@@ -261,10 +261,10 @@ class Check2FAMiddleware(MiddlewareMixin):
|
||||
from allauth.mfa.utils import is_mfa_enabled
|
||||
from allauth.mfa.webauthn.internal.flows import did_use_passwordless_login
|
||||
|
||||
authns = get_authentication_records(request)
|
||||
authns = get_authentication_records(request, request.user)
|
||||
|
||||
return is_mfa_enabled(request.user) and (
|
||||
did_use_passwordless_login(request)
|
||||
did_use_passwordless_login(request, request.user)
|
||||
or any(record.get('method') == 'mfa' for record in authns)
|
||||
)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.views.generic.base import RedirectView
|
||||
import django_filters.rest_framework.filters as rest_filters
|
||||
import structlog
|
||||
from allauth.account.internal.flows.reauthentication import (
|
||||
did_recently_authenticate,
|
||||
did_recently_reauthenticate,
|
||||
get_reauthentication_flows,
|
||||
)
|
||||
from allauth.mfa.utils import is_mfa_enabled
|
||||
@@ -394,7 +394,7 @@ def check_token_reauthentication(request) -> Response | None:
|
||||
"""
|
||||
user = request.user
|
||||
|
||||
if is_mfa_enabled(user) and not did_recently_authenticate(request):
|
||||
if is_mfa_enabled(user) and not did_recently_reauthenticate(request):
|
||||
return Response(
|
||||
{
|
||||
'id': 'reauthentication_required',
|
||||
|
||||
@@ -7,7 +7,11 @@ from unittest import mock
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.urls import reverse
|
||||
|
||||
from allauth.account.internal.flows.login import AUTHENTICATION_METHODS_SESSION_KEY
|
||||
from allauth.account.internal.flows.login import (
|
||||
_AUTHENTICATION_METHODS_USER_SESSION_KEY,
|
||||
AUTHENTICATION_METHODS_SESSION_KEY,
|
||||
)
|
||||
from allauth.account.internal.userkit import user_id_to_str
|
||||
from allauth.account.models import EmailAddress
|
||||
from allauth.mfa.models import Authenticator
|
||||
|
||||
@@ -920,8 +924,14 @@ class UserTokenTests(InvenTreeAPITestCase):
|
||||
"""
|
||||
session = self.client.session
|
||||
session[AUTHENTICATION_METHODS_SESSION_KEY] = [
|
||||
{'method': 'mfa', 'type': 'totp', 'at': time.time() - age}
|
||||
{
|
||||
'method': 'mfa',
|
||||
'type': 'totp',
|
||||
'reauthenticated': True,
|
||||
'at': time.time() - age,
|
||||
}
|
||||
]
|
||||
session[_AUTHENTICATION_METHODS_USER_SESSION_KEY] = user_id_to_str(self.user)
|
||||
session.save()
|
||||
|
||||
def test_token_mfa_reauthentication(self):
|
||||
|
||||
@@ -399,10 +399,17 @@ class MFALoginTest(InvenTreeAPITestCase):
|
||||
self._helper_meta_val(response)
|
||||
|
||||
# Add MFA - trying in a limited loop in case of timing issues
|
||||
rc_code = get_codes(user=self.user)[1][0]
|
||||
rc_codes = get_codes(user=self.user)[1]
|
||||
|
||||
# There must be a TOTP device now - success
|
||||
self.get(reverse('browser:mfa:manage_totp'), expected_code=200)
|
||||
response = self.get(reverse('api-token'), expected_code=401)
|
||||
self.assertEqual(response.data['id'], 'reauthentication_required')
|
||||
self.post(
|
||||
reverse('browser:mfa:reauthenticate'),
|
||||
{'code': rc_codes[0]},
|
||||
expected_code=200,
|
||||
)
|
||||
self.get(reverse('api-token'), expected_code=200)
|
||||
|
||||
# Login with MFA enabled but not provided
|
||||
@@ -419,10 +426,19 @@ class MFALoginTest(InvenTreeAPITestCase):
|
||||
self.get(reverse('api-token'), expected_code=401)
|
||||
# Complete MFA (with recovery code to avoid timing issues)
|
||||
self.post(
|
||||
reverse('browser:mfa:authenticate'), {'code': rc_code}, expected_code=401
|
||||
reverse('browser:mfa:authenticate'),
|
||||
{'code': rc_codes[1]},
|
||||
expected_code=401,
|
||||
)
|
||||
self.post(reverse('browser:mfa:trust'), {'trust': False}, expected_code=200)
|
||||
# and run through trust
|
||||
response = self.get(reverse('api-token'), expected_code=401)
|
||||
self.assertEqual(response.data['id'], 'reauthentication_required')
|
||||
self.post(
|
||||
reverse('browser:mfa:reauthenticate'),
|
||||
{'code': rc_codes[2]},
|
||||
expected_code=200,
|
||||
)
|
||||
self.get(reverse('api-token'), expected_code=200)
|
||||
|
||||
# Login with MFA enabled and provided - but incorrect pwd
|
||||
|
||||
@@ -677,9 +677,9 @@ django==5.2.19 \
|
||||
# djangorestframework
|
||||
# djangorestframework-simplejwt
|
||||
# drf-spectacular
|
||||
django-allauth[headless, mfa, openid, saml, socialaccount]==65.19.6 \
|
||||
--hash=sha256:52f6d31998c0101775b2b5d4fb627a18f3e13c79d863740f762ca476e720be9f \
|
||||
--hash=sha256:efa94dbb9bccf7f29ab7034d176f6a7ab17014c9434867cc7bceea434623ab06
|
||||
django-allauth[headless, mfa, openid, saml, socialaccount]==65.21.1 \
|
||||
--hash=sha256:128344e260a22b62796747be0a2249ad9488a509c1aa34ab35e3fcf22862dd9e \
|
||||
--hash=sha256:7bdf018c9f3f0a32c80677f84e7777272d9c833b180bd6734314c4831c802a9e
|
||||
# via
|
||||
# -c src/backend/requirements.txt
|
||||
# -r src/backend/requirements.in
|
||||
|
||||
@@ -651,9 +651,9 @@ django==5.2.19 \
|
||||
# djangorestframework
|
||||
# djangorestframework-simplejwt
|
||||
# drf-spectacular
|
||||
django-allauth[headless, mfa, openid, saml, socialaccount]==65.19.6 \
|
||||
--hash=sha256:52f6d31998c0101775b2b5d4fb627a18f3e13c79d863740f762ca476e720be9f \
|
||||
--hash=sha256:efa94dbb9bccf7f29ab7034d176f6a7ab17014c9434867cc7bceea434623ab06
|
||||
django-allauth[headless, mfa, openid, saml, socialaccount]==65.21.1 \
|
||||
--hash=sha256:128344e260a22b62796747be0a2249ad9488a509c1aa34ab35e3fcf22862dd9e \
|
||||
--hash=sha256:7bdf018c9f3f0a32c80677f84e7777272d9c833b180bd6734314c4831c802a9e
|
||||
# via -r src/backend/requirements.in
|
||||
django-anymail[amazon-ses, postal]==15.1 \
|
||||
--hash=sha256:299fb12a21ac4101e9706c2ade461d18deacbb6bc3750cfa6ca08aeea1fc9442 \
|
||||
|
||||
Reference in new issue
Block a user