-
Notifications
You must be signed in to change notification settings - Fork 51
fix: enforce() should return True if any result is True #119
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -226,7 +226,8 @@ def oauth_token_request( | |||||||||||||||
| :param password: username password | ||||||||||||||||
| :return: Response from Casdoor | ||||||||||||||||
| """ | ||||||||||||||||
| params = self._get_payload_for_access_token_request(code=code, username=username, password=password) | ||||||||||||||||
| params = self._get_payload_for_access_token_request( | ||||||||||||||||
| code=code, username=username, password=password) | ||||||||||||||||
| return self._oauth_token_request(payload=params) | ||||||||||||||||
|
|
||||||||||||||||
| def _oauth_token_request(self, payload: Dict) -> requests.Response: | ||||||||||||||||
|
|
@@ -292,7 +293,8 @@ def parse_jwt_token(self, token: str, **kwargs) -> Dict: | |||||||||||||||
| :param token: access_token | ||||||||||||||||
| :return: the data in dict format | ||||||||||||||||
| """ | ||||||||||||||||
| certificate = x509.load_pem_x509_certificate(self.certification, default_backend()) | ||||||||||||||||
| certificate = x509.load_pem_x509_certificate( | ||||||||||||||||
| self.certification, default_backend()) | ||||||||||||||||
|
||||||||||||||||
| self.certification, default_backend()) | |
| self.certification, | |
| default_backend(), | |
| ) |
Copilot
AI
Apr 16, 2026
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.
This multiline _build_enforce_params(...) call is unlikely to be Black-compliant (Black will reflow it, typically either to a single line or with a trailing comma + closing paren on its own line). Please run Black or adjust formatting accordingly so CI/pre-commit passes.
| permission_id, model_id, resource_id, enforce_id, owner) | |
| permission_id, | |
| model_id, | |
| resource_id, | |
| enforce_id, | |
| owner, | |
| ) |
Copilot
AI
Apr 16, 2026
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.
CasdoorSDK.enforce() now returns True if any boolean in data is True, but AsyncCasdoorSDK.enforce() (src/casdoor/async_main.py) still returns only data[0]. This creates inconsistent behavior between the sync and async SDKs for the same API; consider updating the async implementation in the same way to keep parity.
Copilot
AI
Apr 16, 2026
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.
The updated multi-result aggregation behavior (return True if any result is True) isn’t covered by existing tests: current enforce tests only assert the return type. Please add a test that mocks/fixtures the Casdoor response with data: [False, True] (and [False, False]) to verify the new semantics and prevent regressions.
Copilot
AI
Apr 16, 2026
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.
This _build_enforce_params(...) call has the same non-Black-compliant multiline formatting pattern as above. Please run Black or reformat so the pre-commit Black hook in CI doesn’t fail.
| permission_id, model_id, "", enforce_id, owner) | |
| permission_id, | |
| model_id, | |
| "", | |
| enforce_id, | |
| owner, | |
| ) |
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.
These manual line breaks don’t match the repository’s Black formatting (see pre-commit/CI), and Black will likely collapse this call back to a single line (or reflow it with the closing paren on its own line). Please run Black or format this call in a Black-compliant way to avoid CI/pre-commit failures.