django-ninja
django-ninja copied to clipboard
[BUG] Multiple authenticators fail to choose the appropriate one in the end
When specifying multiple authenticators in a @router.get
decorator, it seems that the order of those authenticators matter when it should not.
Example: http://localhost:8000/api/hops?stravapp-api-key=Fakekey
will work when queried in the browser only if StravAPIKeyQuery is placed first:
@router.get("/hops", auth=[StravAPIKeyQuery(), StravAPIKeyHeader()])
def GetOrderedHops(request):
user = request.auth
...
will work, but:
@router.get("/hops", auth=[StravAPIKeyHeader(), StravAPIKeyQuery()])
def GetOrderedHops(request):
user = request.auth
...
won't.
The opposite is true when putting that key in a header. It's like if only the first one in the list is being used to extract a key!
Versions:
- Python version: 3.11.2
- Django version: 5.0.1
- Django-Ninja version: 1.1.0
- Pydantic version: 2.5.3