Skip to content

Commit

Permalink
MULTIPLE BUG FIXES
Browse files Browse the repository at this point in the history
SDK NOW SUPPORTS PY FORM 3.2.1 TO LATEST STABLE version

Update trustauthx to version 0.8.3

The `setup.py` file has been updated to reflect the new version number (0.8.3).

In `trustauthx/authlite.
  • Loading branch information
moonlightnexus committed Apr 25, 2024
1 parent 376c201 commit 6fac4f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="trustauthx",
version="0.8.1",
version="0.8.3",
description="Official connector SDK for TrustAuthx",
long_description=long_description,
long_description_content_type="text/markdown", # This is important!
Expand Down
42 changes: 22 additions & 20 deletions trustauthx/authlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def delete_permission(
url, headers=headers, params=params, data=json.dumps(data)
)
self.reinitialize_all(foreground)
return response.json()
return DeletePermissionResponse(**response.json())


class AuthLiteClient:
Expand Down Expand Up @@ -601,6 +601,7 @@ def __init__(
self._signed_key = self.jwt_encode(
key=self._secret_key, data={"api_key": self._api_key}
)
# print(f"{(self._api_key, self.org_id, self._signed_key)}")
self.API_BASE_URL = API_BASE_URL
self.in_memory = in_memory
self.Roles: _Roles = _Roles(
Expand Down Expand Up @@ -717,9 +718,9 @@ def get_user(self, token, return_class=False) -> Union[User, dict]:
rtn["email"] = sub["email"]
rtn["uid"] = sub["uid"]
if not return_class:
return User(rtn).to_dict()
return rtn
else:
return User(rtn)
return User(**rtn)
else:
raise HTTPError(
"Request failed with status code : {} \n this code contains a msg : {}".format(
Expand Down Expand Up @@ -898,7 +899,8 @@ def _set_edge_roles(self) -> list:
"signed_key": f"{self._signed_key}",
}
response = requests.get(url, headers=headers, params=params)
roles = [Role(**role_data) for role_data in response.json()]
response_text = response.json()
roles = [Role(**role_data) for role_data in response_text]
roles = GetAllRolesResponse(
roles_list=roles, roles_json_list=[asdict(role) for role in roles]
)
Expand Down Expand Up @@ -959,9 +961,9 @@ def attach_role(
"signed_key": self._signed_key,
}
rols = []
if isinstance(rol_ids) == str:
if isinstance(rol_ids, str):
rols.append(rol_ids)
elif isinstance(rol_ids) == list:
elif isinstance(rol_ids, list):
rols = [i for i in rol_ids]
else:
raise TypeError()
Expand All @@ -974,13 +976,13 @@ def attach_role(
"RefreshToken": refresh_token,
}
response = requests.post(url, headers=headers, params=params, json=data)
if signoff_session_and_assign:
if not signoff_session_and_assign:
return response.json()
else:
if return_class:
return SignOffSessionReplace(response.json())
return SignOffSessionReplace(**response.json())
else:
return SignOffSessionReplace(response.json()).to_dict()
return SignOffSessionReplace(**response.json()).to_dict()

def remove_role(
self,
Expand Down Expand Up @@ -1024,9 +1026,9 @@ def remove_role(
"signed_key": self._signed_key,
}
rols = []
if isinstance(rol_ids) == str:
if isinstance(rol_ids, str):
rols.append(rol_ids)
elif isinstance(rol_ids) == list:
elif isinstance(rol_ids,list):
rols = [i for i in rol_ids]
else:
raise TypeError()
Expand All @@ -1039,13 +1041,13 @@ def remove_role(
"RefreshToken": refresh_token,
}
response = requests.post(url, headers=headers, params=params, json=data)
if signoff_session_and_assign:
if not signoff_session_and_assign:
return response.json()
else:
if return_class:
return SignOffSessionReplace(response.json())
return SignOffSessionReplace(**response.json())
else:
return SignOffSessionReplace(response.json()).to_dict()
return SignOffSessionReplace(**response.json()).to_dict()

def update_role(
self,
Expand Down Expand Up @@ -1091,16 +1093,16 @@ def update_role(
"signed_key": self._signed_key,
}
rols_add = []
if isinstance(rol_ids_to_add) == str:
if isinstance(rol_ids_to_add, str):
rols_add.append(rol_ids_to_add)
elif isinstance(rol_ids_to_add) == list:
elif isinstance(rol_ids_to_add, list):
rols_add = [i for i in rol_ids_to_add]
else:
raise TypeError()
rols_rem = []
if isinstance(rol_ids_to_remove) == str:
if isinstance(rol_ids_to_remove,str):
rols_rem.append(rol_ids_to_remove)
elif isinstance(rol_ids_to_remove) == list:
elif isinstance(rol_ids_to_remove, list):
rols_rem = [i for i in rol_ids_to_remove]
else:
raise TypeError()
Expand All @@ -1117,6 +1119,6 @@ def update_role(
return response.json()
else:
if return_class:
return SignOffSessionReplace(response.json())
return SignOffSessionReplace(**response.json())
else:
return SignOffSessionReplace(response.json()).to_dict()
return SignOffSessionReplace(**response.json()).to_dict()

0 comments on commit 6fac4f5

Please sign in to comment.