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() with "with_children=true" not working for child roles #33

Open
ianteohsc opened this issue Sep 6, 2021 · 0 comments
Open

allow() with "with_children=true" not working for child roles #33

ianteohsc opened this issue Sep 6, 2021 · 0 comments

Comments

@ianteohsc
Copy link

ianteohsc commented Sep 6, 2021

Referring to the unit test as an example, my expectation is that accessing /e as a staff_role_user should work because staff_role_user is a child of everyone. But from my testing, this is not true.

  @app.route('/e')
  @after_decorator
  @rbac.deny(roles=['everyone'], methods=['GET'], with_children=True)
  @before_decorator
  def e():
      return Response('Hello from /e')
.
.
.
  def test_allow_get_view(self):
      global current_user
      current_user = normal_user
      self.assertEqual(self.client.open('/d').data.decode('utf-8'), 'Hello from /d')

      current_user = staff_role_user
      self.assertEqual(self.client.open('/d').data.decode('utf-8'), 'Hello from /d')
      self.assertEqual(self.client.open('/e').data.decode('utf-8'), 'Hello from /e') #Condition not tested

My suspicion is that during the _setup_acl method, there is no check for acls already in the allow list before adding to deny list AND with_children needs to be removed so that allow's with_children can take effect.


        for rn, method, resource, with_children in self.before_acl['deny']:
            role = self._role_model.get_by_name(rn)
            if not self.acl.is_allowed(rn,method,resource): #This check is missing
                self.acl.deny(role, method, resource) #with_children needs to be removed


I'm new to flask-rbac, appreciate if someone can confirm my findings above.

Thank you.

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

1 participant