Skip to content

Enhancement over multiple authenticators #1443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chang-ph opened this issue Apr 10, 2025 · 1 comment
Open

Enhancement over multiple authenticators #1443

chang-ph opened this issue Apr 10, 2025 · 1 comment

Comments

@chang-ph
Copy link

Is your feature request related to a problem? Please describe.

Currently django-ninja supports muliple authenticators. But it's too simple in that it only support the "OR" relationship of the authenticators. If all the authenticators are invalid, it will raise an authentication error to the response.

Related materials:

  1. The section in the OpenAPI specification about multiple authenticators

  2. A more readable guide

Describe the solution you'd like

I think syntax like this may be appropiate:

@api.get("/multiple", auth=[QueryKey(), [Header1Key(), Header2Key()]])
def multiple(request):
    return f"Token = {request.auth}"

Where the first level in the list is OR related and the second level([Header1Key(), Header2Key()]) is AND related.

@vitalik
Copy link
Owner

vitalik commented Apr 10, 2025

@chang-ph well the thing is authenticator must return some object (e.g. user or token or company some prinicipal)

and this object is then set to request.auth

in case of AND logic is not really clear what you expect to see in request.auth ? a list or just some boolean value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants