Skip to content
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

Authentication AND/OR operators #197

Closed
wants to merge 6 commits into from
Closed

Authentication AND/OR operators #197

wants to merge 6 commits into from

Conversation

igoose1
Copy link
Contributor

@igoose1 igoose1 commented Aug 10, 2021

That closes #196.

After merging this will be possible:

@api.get(
    "/",
    auth=(Auth1() & Auth2()) | Auth3()),
)
def f(request):
    pass

What I don't like at this moment (marked lines are solved):

  • AuthBase.__call__ now is not abstractmethod, I used it for recursive descent. The previous method is renamed to "callable" and it's not the best name.

  • Swagger docs aren't built for operators. Must be something like this: https://swagger.io/docs/specification/authentication/#multiple

  • No clear error messages when trying to pair with "just callable".

  • Django-ninja docs aren't yet written.

The PR is in progress. Comments are welcome!

Oskar Sharipov added 4 commits August 11, 2021 01:31
That closes #196.

After merging this will be possible:

    @api.get(
	"/",
	auth=(Auth1() & Auth2()) | Auth3()),
    )
    def f(request):
	pass

What I don't like at this moment:

    * AuthBase.__call__ now is not abstractmethod, I used it for
      recursive descent. The previous method is called "callable" and
      it's not the best name.

    * Swagger docs is not built for operators. Must be something like
      this:
      https://swagger.io/docs/specification/authentication/#multiple

    * Django-ninja docs aren't yet written.

    * No clear error messages when trying to pair with "just callable".
@igoose1
Copy link
Contributor Author

igoose1 commented Aug 11, 2021

Note: it's impossible to unite typing.Callable and AuthBase. That's, and in order of compatibility, why the "old" way is kept as it was before. I've just added some tests, there were none of them testing the sequence in auth=....

This pull request was closed.
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

Successfully merging this pull request may close these issues.

Authentications with logical operators
1 participant