Skip to content

Commit

Permalink
fix: data-resource-claims doesn't have to exist
Browse files Browse the repository at this point in the history
  • Loading branch information
siyoungbyun authored Jul 14, 2021
1 parent 3ceb154 commit 08931b1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bhjwt/assertions/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ def is_data_resource_user_of(self, data_resource_id):
self._is_data_resource_role_of(data_resource_id, "user")

def _has_permission_to_data_resource(self, data_resource_id: str, permission: str) -> None:
data_resource_claim = self.claims["brighthive-data-resource-claims"].get(data_resource_id)
data_perm = f"data:{permission.lower()}"
assertion = ("brighthive-data-resource-claims" in self.claims and
data_resource_claim is not None and
data_perm in data_resource_claim.get("permissions", []))
assertion = (
"brighthive-data-resource-claims" in self.claims
and self.claims["brighthive-data-resource-claims"].get(data_resource_id)
is not None
and permission
in self.claims["brighthive-data-resource-claims"]
.get(data_resource_id)
.get("permissions", [])
)
self.assertions.append(assertion)

def has_edit_to_data_resource(self, data_resource_id):
Expand Down

0 comments on commit 08931b1

Please sign in to comment.