Skip to content

Commit 29f4c73

Browse files
committed
Fix log out url part
1 parent 8f1ec0c commit 29f4c73

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

workos/session.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(
3030

3131
self.jwks = PyJWKClient(self.user_management.get_jwks_url())
3232

33+
# Algorithms are hardcoded for security reasons. See https://pyjwt.readthedocs.io/en/stable/algorithms.html#specifying-an-algorithm
3334
self.jwk_algorithms = ['RS256']
3435

3536
def authenticate(
@@ -119,20 +120,19 @@ def refresh(self, options: Optional[Dict[str, Any]] = None) -> Union[
119120
def get_logout_url(self) -> str:
120121
auth_response = self.authenticate()
121122

122-
if not auth_response["authenticated"]:
123-
raise ValueError(auth_response["reason"])
123+
if not auth_response.authenticated:
124+
raise ValueError(f"Failed to extract session ID for logout URL: {auth_response.reason}")
124125

125126
return self.user_management.get_logout_url(
126-
session_id=auth_response["session_id"]
127+
session_id=auth_response.session_id
127128
)
128129

129130
def is_valid_jwt(self, token: str) -> bool:
130131
try:
131132
signing_key = self.jwks.get_signing_key_from_jwt(token)
132133
jwt.decode(token, signing_key.key, algorithms=self.jwk_algorithms)
133134
return True
134-
except jwt.exceptions.InvalidTokenError as error:
135-
print("invalid token", error)
135+
except jwt.exceptions.InvalidTokenError:
136136
return False
137137

138138
@staticmethod

workos/types/user_management/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class AuthenticateWithSessionCookieSuccessResponse(WorkOSModel):
1818
permissions: Optional[List[str]] = None
1919
user: User
2020
impersonator: Optional[Impersonator] = None
21+
entitlements: Optional[List[str]] = None
2122

2223
class AuthenticateWithSessionCookieErrorResponse(WorkOSModel):
2324
authenticated: bool = False

0 commit comments

Comments
 (0)