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

Combining permissions with -OR- #2350

Open
1 of 3 tasks
paulo-raca opened this issue Nov 16, 2022 · 1 comment · May be fixed by #3315
Open
1 of 3 tasks

Combining permissions with -OR- #2350

paulo-raca opened this issue Nov 16, 2022 · 1 comment · May be fixed by #3315
Labels
enhancement New feature or request

Comments

@paulo-raca
Copy link
Contributor

paulo-raca commented Nov 16, 2022

In my project I have resolvers that should be acessible if at least one of multiple conditions is met -- aka "OR".

I'm currently implementing it in a single permission class, but it would be ideal if I could combine them. A few examples:

@strawberry.type
class Mutation:
    @strawberry.mutation(permission=Permissions.SuperAdmin | Permission.ObjectOwner)
    def update_object(self, object_id: ID, changes: Something) -> MutationResult:
        ...
@strawberry.type
class ParentChildRelationship:
    @strawberry.field(permission=Permissions.IsParent | Permissions.IsChild)
    def relationship_details(self) -> Something:
        ...

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@DoctorJohn DoctorJohn added the enhancement New feature or request label Nov 29, 2022
@DoctorJohn
Copy link
Member

DoctorJohn commented Nov 29, 2022

I thought about this a few times before. Kinda tempting to mimic the way it's implemented in the django-rest-framework. So far I always ended up implementing separate permission classes for basically all my protected fields. Guess this could be a nice feature enabling more shared code.

I think we were discussing the state of permissions in our roadmap to v1 before. Personally, I would welcome related PRs, what do you think @patrick91 ?

@replygirl replygirl linked a pull request Jan 3, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants