Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Check permissions on incoming requests #291

Merged
merged 39 commits into from Jun 10, 2015
Merged

Conversation

almet
Copy link
Contributor

@almet almet commented Jun 5, 2015

Adds permissions check to cliquet applications:

  • Create a context factory to provide information about the requested objects;
  • Update the authorization policy to look at what's contained in the context;
  • Change the default permission to be dynamic;
  • Add unit tests for context factory;
  • Add unit tests for authorization policy;
  • Update the functional tests;
  • Add functional tests without mocking authorization.

To review:

  • Naming and conventions;
  • Tests;
  • I've updated the tests to use another fake authz backend, I think that would make everything easier to test, but that can be discussed.

@almet almet added the to review label Jun 5, 2015
@almet almet force-pushed the permissions-context-factory branch from ee9b091 to a294690 Compare June 8, 2015 15:30
@almet almet changed the title [DO NOT MERGE] Permissions context factory Permissions context factory Jun 9, 2015
"""
raise NotImplementedError

def object_permission_principals(self, object_id, permission):
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to get_ace_principals

@almet almet changed the title Permissions context factory Check permissions on incoming requests Jun 9, 2015
from cliquet import utils
from cliquet.initialization import ( # NOQA
initialize, initialize_cliquet, install_middlewares)

# Main Cliquet logger.
logger = structlog.get_logger()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that #102 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's just to make flake8 happy (otherwise imports are after an instruction)

This avoids passing around information to the authorization policy when it's
not necessary. Here, at the definition time, the function is curried with the
known arguments.

From a review by @leplatrem.
The former could be a boolean flag. Here it's explicit it is doing an
operation.

From a review by @leplatrem
Rather than using a string, which is error prone, having a constant allows to
catch errors earlier in the dev process.
almet added a commit that referenced this pull request Jun 10, 2015
…tory

Check permissions on incoming requests
@almet almet merged commit 36e5d76 into master Jun 10, 2015
@almet almet removed the to review label Jun 10, 2015
@almet almet deleted the permissions-context-factory branch June 10, 2015 13:23
@leplatrem leplatrem modified the milestone: 2.0 Jun 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants