-
Notifications
You must be signed in to change notification settings - Fork 25
Fix/token decode issue #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/token decode issue #54
Conversation
WalkthroughThe pull request updates two methods in the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant KindeApiClient
Client->>KindeApiClient: is_authenticated_token(token_value)
alt Token valid (not expired)
KindeApiClient-->>Client: Returns True
else Token expired
KindeApiClient-->>Client: Returns default response
end
sequenceDiagram
participant Caller
participant KindeApiClient
Caller->>KindeApiClient: _decode_token_if_needed_value(token_name, token_value)
KindeApiClient->>KindeApiClient: Retrieve token using token_value.get(token_name)
alt Token exists
KindeApiClient->>KindeApiClient: Decode token using signing key
KindeApiClient-->>Caller: Returns decoded token dictionary
else Token not found
KindeApiClient-->>Caller: Raises KindeTokenException
end
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
kinde_sdk/kinde_api_client.py (1)
338-356: Simplified token decoding logicThe token decoding logic has been improved by eliminating redundant checks and directly retrieving the token value. This is a cleaner implementation that maintains proper error handling.
There's an unnecessary semicolon at the end of line 354 that should be removed:
- return {token_name: jwt.decode(**decode_token_params)}; + return {token_name: jwt.decode(**decode_token_params)}Also, the method signature indicates the return type is
dict, which is correct for the implementation, but the AI summary indicates it was changed to returnNone. Please verify this is intentional:-def _decode_token_if_needed_value(self, token_name: str, token_value: dict) -> dict: +def _decode_token_if_needed_value(self, token_name: str, token_value: dict) -> None:The actual implementation returns a dictionary, so the return type should remain
dict.🧰 Tools
🪛 Ruff (0.8.2)
354-354: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
kinde_sdk/kinde_api_client.py(2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
kinde_sdk/kinde_api_client.py
354-354: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
kinde_sdk/kinde_api_client.py (1)
357-357: Remove unnecessary semicolonThe statement ends with an unnecessary semicolon, which is not a Python convention.
- return {token_name: jwt.decode(**decode_token_params)}; + return {token_name: jwt.decode(**decode_token_params)}🧰 Tools
🪛 Ruff (0.8.2)
357-357: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
kinde_sdk/kinde_api_client.py(2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
kinde_sdk/kinde_api_client.py
357-357: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
🔇 Additional comments (2)
kinde_sdk/kinde_api_client.py (2)
137-142: Return type inconsistency in is_authenticated_token methodThe method signature indicates this method returns a
dictbut the implementation now returnsTruefor authenticated tokens andNoneotherwise. This creates a type mismatch between the declared return type and the actual return values.The method signature should be updated to reflect the actual return type:
-def is_authenticated_token(self, token_value: dict) -> dict: +def is_authenticated_token(self, token_value: dict) -> bool:Also, consider updating the method to return
Falseinstead ofNoneto maintain consistency with the boolean return type:- return None + return False
338-359:⚠️ Potential issueReturn type inconsistency in _decode_token_if_needed_value method
The method signature indicates this method returns a
dictbut according to the AI summary, it has been changed to returnNone. However, the implementation actually returns a dictionary. Update the method signature to accurately reflect the return type.-def _decode_token_if_needed_value(self, token_name: str, token_value: dict) -> dict: +def _decode_token_if_needed_value(self, token_name: str, token_value: dict) -> dict:Also, verify that all calling code expects a dictionary return value.
Likely an incorrect or invalid review comment.
🧰 Tools
🪛 Ruff (0.8.2)
357-357: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
kinde_sdk/kinde_api_client.py(2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
kinde_sdk/kinde_api_client.py
356-356: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
🔇 Additional comments (3)
kinde_sdk/kinde_api_client.py (3)
137-142: Return type inconsistency in is_authenticated_token methodThe method signature indicates this method returns a
dictbut the implementation now returnsTruefor authenticated tokens andNoneotherwise. This creates a type mismatch between the declared return type and the actual return values.The method signature should be updated to reflect the actual return type:
-def is_authenticated_token(self, token_value: dict) -> dict: +def is_authenticated_token(self, token_value: dict) -> bool:Also, consider updating the method to return
Falseinstead ofNoneto maintain consistency with the boolean return type:- return None + return False
338-342: Improved error handling for token validationThe new implementation correctly simplifies token retrieval using
get()and properly checks if the token is a string. This is a good improvement that makes the code more robust.
344-357: Well-structured JWT token decoding implementationThe restructured JWT decoding logic is now more straightforward and properly handles the case when a signing key exists. The code is now more maintainable and easier to follow.
🧰 Tools
🪛 Ruff (0.8.2)
356-356: Statement ends with an unnecessary semicolon
Remove unnecessary semicolon
(E703)
|
Hello, I have had the chance to run tests on this, I can confirm everything is running soundly on my end. I haven't encountered any issues thus far |
Explain your changes
This fixes the token decoding logic in place for the user_details extraction.
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.