Skip to content

Commit

Permalink
Merge pull request #9 from Ur-Solutions/feature/implement-new-guard-s…
Browse files Browse the repository at this point in the history
…ystem

Feature/implement new guard system
  • Loading branch information
tOgg1 committed Feb 2, 2021
2 parents 445499f + 9e98ef7 commit af9799f
Show file tree
Hide file tree
Showing 16 changed files with 1,133 additions and 142 deletions.
7 changes: 4 additions & 3 deletions django_scoped_permissions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def scope_grants_permission(
if granting_scope.startswith("="):
expanded_scopes = expand_scopes_with_verb([required_scope], verb)
else:
expanded_scopes = expand_scopes_with_verb_recursively(
[required_scope], verb
)
expanded_scopes = expand_scopes_with_verb_recursively([required_scope], verb)

return any_scope_matches(expanded_scopes, [granting_scope])

Expand All @@ -52,6 +50,9 @@ def scopes_grant_permissions(
4. If the user has a scope that matches any of the scopes, we return True.
5. Return False
"""
if len(required_scopes) == 0:
return True

exclude_exact, include_exact, exclude, include = partition_scopes(granting_scopes)

required_base_scopes_with_verb = expand_scopes_with_verb(required_scopes, verb)
Expand Down

0 comments on commit af9799f

Please sign in to comment.