django-ninja
django-ninja copied to clipboard
[BUG] Setting auth=None at the router level doesn't disable auth for the router when using global auth
Bug Description
When using global auth like this:
api = NinjaAPI(auth=SomeAuth())
I expect to be able to exempt some routers by using auth=None
at the router level:
# Either when creating the router
some_router = Router(auth=None)
# Or when registering the router
api.add_router('/some/path', some_router, auth=None)
- In both scenarios, the router paths are still being evaluated by
SomeAuth
. - If
auth=None
is set at the endpoint level, it works as expected.
I've isolated it in this repo: https://github.com/joseph-sabido/django-router-bug/blob/master/core/api.py
Another very likely explanation, is that I'm doing it wrong 😄
Versions (please complete the following information):
- Python version: 3.9.6
- Django version: 4.2.8
- Django-Ninja version: 1.1.0
- Pydantic version: 2.5.2