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

permissions: not working on not logged users #56

Closed
wants to merge 2 commits into from

Conversation

remileduc
Copy link
Member

I've added several tests for invenio-access, particularly for actions with arguments, and for not logged users.

Globally, we should have the following:

parameterized actions

Imagine you have 2 users: user1 and user2, and 2 actions: action1 and action2.
You have the following actions users table:

id user action parameter
1 action1
2 user1 action1 p1
3 user1 action2
4 user2 action2 p1
  1. The action1 and all its children (action1 with any parameters) will be accessible by anybody because of the first rule.
  2. The second rule says that only user1 can access to the action1, but it is useless because of the rule 1.
  3. The third rule says that only user1 can access to action2.
  4. Finally, the last rule says that user2 can access to action2 with p1 parameter.

To summarize, user1 can access everything.
user2 can only action1 and action1 with any parameters. He can also access to action2 but only with parameter p1
Finally, a not-logged user will be able to access action1, but that's all.

The problem I actually have is the overriden rules explained in rules 1 and 2. Actually the test fails at line 131 (the only assert that fails), while this should pass.

See the comments for more details.


assert not permission_open.allows(identity_unknown)
assert not permission_read.allows(identity_unknown)
assert permission_not_logged.allows(identity_unknown)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we are in the case of rule 1 in the description of this PR. So, anybody, including not logged users, should access to this action.

@jirikuncar jirikuncar self-assigned this May 12, 2016
@jirikuncar jirikuncar added this to the v1.0.0 milestone May 12, 2016
@remileduc remileduc changed the title tests: add tests for permissions with arguments bug: permissions not working on not logged users May 13, 2016
@jirikuncar jirikuncar changed the title bug: permissions not working on not logged users permissions: not working on not logged users May 23, 2016
@PXke
Copy link
Member

PXke commented Aug 12, 2016

Is there a command to rerun Travis ?

@jirikuncar
Copy link
Member

You should be able to re-run the travis build since you have write access. Or simply close/open the PR. However, this branch has conflicts that must be resolved.

@remileduc
Copy link
Member Author

the tests will never pass on this branch as it is its purpose: to show a problem in the current invenio-access module. See it as a test case. This PR doesn't provide any solution to fix the issue.

I can rebase though, I'll do it when I'll have a bit of time

@remileduc
Copy link
Member Author

I've updated to the last version, it still crashes at the same point ;)

@lnielsen lnielsen modified the milestones: v1.0.0, someday May 12, 2017
drjova pushed a commit that referenced this pull request May 23, 2017
* Uses argument instead of option for required parameters. (closes #56)

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
@lnielsen lnielsen modified the milestones: v1.0.0, someday Jun 14, 2017
@remileduc
Copy link
Member Author

New version, fixes the main problem with no users:

  • it is now impossible to create an action with no users. THUS, it is no longer possible to allow or deny all users from an action.
  • in the future, we may have to create new explicit groups like "anyusers"

@@ -61,7 +61,7 @@ def upgrade():
sa.Column('exclude', sa.Boolean(name='exclude'), server_default='0',
nullable=False),
sa.Column('argument', sa.String(length=255), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=False),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need an alembic recipe for this change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would this recipe do? only change the "NOT NULL" or try to do some other smart things?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only put it to "NOT NULL" so we have a predictable behavior. If set to NULL, we can have some issues, as described in the decsription

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok no problem for B2SHARE then.

@@ -119,14 +119,6 @@ def allow_action(action, argument):
"""Allow action."""


@allow_action.command('any')
def allow_any():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nharraud Will removal of these impact you on B2SHARE?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. We always assign permissions to specific users or have a permission factory which allow/forbids everybody.

@remileduc remileduc force-pushed the master branch 2 times, most recently from 6515412 to 4193ea0 Compare August 3, 2017 08:08
- remove the possibility to create an ActionUsers without user
  doesn't make sens... We may have to implement special cases
  in the future like 'anyuser'...
- use the travis user instead of root to make the tests pass
  (maybe something has changed since travis is using Trusty as
  default distrib)
- use precise distrib
@lnielsen
Copy link
Member

lnielsen commented Aug 3, 2017

@lnielsen lnielsen closed this Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants