Skip to content

Commit

Permalink
Merge pull request #49 from permitio/asaf/cto-136-fix-python-sdk-not-…
Browse files Browse the repository at this point in the history
…encoding-permit-check-input-correctly

Fix Python SDK not encoding permit check input correctly
  • Loading branch information
asafc authored Dec 11, 2023
2 parents 2832ef1 + 401f6b8 commit 3ac9af8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions permit/enforcement/enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ async def check(
)
query_context = self._context_store.get_derived_context(context)
input = dict(
user=normalized_user.dict(),
user=normalized_user.dict(exclude_unset=True),
action=action,
resource=normalized_resource.dict(),
resource=normalized_resource.dict(exclude_unset=True),
context=query_context,
)

Expand Down Expand Up @@ -171,8 +171,8 @@ def _normalize_resource(self, resource: ResourceInput) -> ResourceInput:
@staticmethod
def _resource_repr(resource: ResourceInput) -> str:
resource_repr: str = resource.type
if resource.id is not None:
resource_repr += ":" + resource.id
if resource.key is not None:
resource_repr += ":" + resource.key
if resource.tenant:
resource_repr += f", tenant: {resource.tenant}"
return resource_repr
Expand All @@ -182,7 +182,7 @@ def _resource_from_string(resource: str) -> ResourceInput:
parts = resource.split(RESOURCE_DELIMITER)
if len(parts) < 1 or len(parts) > 2:
raise ValueError(f"permit.check() got invalid resource string: {resource}")
return ResourceInput(type=parts[0], id=(parts[1] if len(parts) > 1 else None))
return ResourceInput(type=parts[0], key=(parts[1] if len(parts) > 1 else None))


class SyncEnforcer(Enforcer, metaclass=SyncClass):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def get_requirements(env=""):

setup(
name="permit",
version="2.1.0rc2",
version="2.1.0",
packages=find_packages(),
author="Asaf Cohen",
author_email="[email protected]",
Expand Down

0 comments on commit 3ac9af8

Please sign in to comment.