You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
API request with enabled auth permission_classes = [HasAPIKey] process about a second, without - 14 ms
To Reproduce
Steps to reproduce the behavior:
pip install "djangorestframework-api-key==2.3.0"
Configure (as in the documentation)
Add permission_classes = [HasAPIKey] to ViewSet class API handler
See result
Expected behavior
Expected to work without significant delays.
Desktop (please complete the following information):
OS: MacOS
Version: 10.13.6
Python Version: 3.11.5
Django Version: 4.2.4
DRF Version: 3.14.0
How did I fix it
As a quick solution, I removed the recursive call in models.py, class BaseAPIKeyManager - method get_from_key call is_valid and vice versa. Perhaps it was a mistake - now all works correct, the request is processed in 14 ms
defget_from_key(self, key: str) ->"AbstractAPIKey":
prefix, _, _=key.partition(".")
queryset=self.get_usable_keys()
try:
api_key=queryset.get(prefix=prefix)
exceptself.model.DoesNotExist:
raise# For the sake of being explicit.# if not api_key.is_valid(key):# raise self.model.DoesNotExist("Key is not valid.")# else:returnapi_key
The text was updated successfully, but these errors were encountered:
Describe the bug
API request with enabled auth
permission_classes = [HasAPIKey]
process about a second, without - 14 msTo Reproduce
Steps to reproduce the behavior:
pip install "djangorestframework-api-key==2.3.0"
permission_classes = [HasAPIKey]
to ViewSet class API handlerExpected behavior
Expected to work without significant delays.
Desktop (please complete the following information):
How did I fix it
As a quick solution, I removed the recursive call in
models.py
,class BaseAPIKeyManager
- methodget_from_key
callis_valid
and vice versa. Perhaps it was a mistake - now all works correct, the request is processed in 14 msThe text was updated successfully, but these errors were encountered: