From 08931b17ddf2df1b326e29726dc8ca9316399dd4 Mon Sep 17 00:00:00 2001 From: Si Young Byun <70714904+siyoungbyun@users.noreply.github.com> Date: Wed, 14 Jul 2021 11:25:45 -0500 Subject: [PATCH] fix: data-resource-claims doesn't have to exist --- bhjwt/assertions/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bhjwt/assertions/main.py b/bhjwt/assertions/main.py index 9f86e28..0a59f2c 100644 --- a/bhjwt/assertions/main.py +++ b/bhjwt/assertions/main.py @@ -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):