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

Allow boolean operations between authorization items #236

Open
taion opened this issue Feb 18, 2019 · 2 comments
Open

Allow boolean operations between authorization items #236

taion opened this issue Feb 18, 2019 · 2 comments

Comments

@taion
Copy link
Contributor

taion commented Feb 18, 2019

For combining authorization, in many cases it would be simpler to do something like:

class WidgetView(GenericModelView):
    authorization = WidgetAuthorization() | AdminAuthorization()

Instead of having to define a new authorization class that combines the two in a less declarative manner.

Inspired by the permission_classes functionality in DRF.

@sloria
Copy link
Member

sloria commented Feb 18, 2019

I like the idea.

Out of the box, DRF just runs permission_classes serially, but there are 3rd-party packages that allow you to compose permissions, e.g. https://github.com/caxap/rest_condition .

EDIT: Ah, looks like DRF does support composable permissions in recent releases.

@sloria
Copy link
Member

sloria commented Sep 6, 2019

Tangentially related: it might be nice have a way to combine other objects like Filtering. This could be useful for mixins and base classes.

class MyEntityMixin:
    filtering = Filtering(id=operator.eq, ..)

class WidgetView(MyEntityMixin, GenericModelView):
    filtering = MyEntityMixin.filtering | Filtering(factory_id=operator.eq)

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