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

Fallback to Model Permissions (Core) #546

Closed
wants to merge 6 commits into from
Closed

Fallback to Model Permissions (Core) #546

wants to merge 6 commits into from

Conversation

doganmeh
Copy link

Related to #380, and #49.

This updates core.py and test_core.py to allow the following checker functions optionally fallback to (or include) model level permissions:

get_user_perms(self, obj, fallback_to_model=None)
get_group_perms(self, obj, fallback_to_model=None)
get_perms(self, obj, fallback_to_model=None)

Please note the fallback_to_model parameter.

This also includes, a global setting two that end: FALLBACK_TO_MODEL. Function level takes precedence if both provided. Overall defaults to False in order not to change the default behavior.

When get_perms is used with fallback_to_model=True, the combined permissions go through the existing caching mechanism, so a performance degradation is not expected (although not tested).

Tests are implemented, but documentation is not. More is planned.

@doganmeh
Copy link
Author

previous commit adds standalone cache for model level permissions even if directly accessed via get_user_perms and get_group_perms

@doganmeh
Copy link
Author

I now more firmly believe that falling back to model permissions should be via falling back to django default backend, not within Guardian. While this is in the mean time (that was what it was meant to be) useful; should eventually be get rid of. I also have a pull request at Django to help this. Maybe it is better not to pull this in, in hopes that, that one will be.

@doganmeh doganmeh closed this Jan 16, 2018
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

Successfully merging this pull request may close these issues.

None yet

1 participant