feat: fix enforce param name from enforceId to enforcerId #111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: #110
Problem
The
enforce()andbatch_enforce()methods in both sync and async implementations incorrectly useenforceIdas the query parameter name when calling the Casdoor API. The correct parameter name isenforcerId(note the 'r').This bug causes the enforce API to silently return
falsefor all authorization checks when using an Enforcer object, regardless of the actual policy rules. This is a security concern as it fails closed without raising any errors.Related Issue
Fixes #110
Changes
Fixed parameter name in all 4 affected methods:
src/casdoor/main.py:enforce()andbatch_enforce()src/casdoor/async_main.py:enforce()andbatch_enforce()Changed
params["enforceId"]toparams["enforcerId"]in all locations.Also added parameter validation to ensure exactly one of (permission_id, model_id, resource_id, enforce_id, owner) is provided, improving error messages when the API is called incorrectly.
Testing
Breaking Changes
None - this fixes existing broken functionality.