Conversation
|
|
…nforcer with tests Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add missing APIs from Go Casbin to jCasbin
Sync AddNamedGroupingPoliciesEx APIs from Go Casbin to jCasbin
Oct 11, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #463 +/- ##
==========================================
+ Coverage 66.77% 67.30% +0.52%
==========================================
Files 60 60
Lines 2992 3000 +8
Branches 557 557
==========================================
+ Hits 1998 2019 +21
+ Misses 811 802 -9
+ Partials 183 179 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
AddGroupingPoliciesEx and AddNamedGroupingPoliciesEx APIs to sync jCasbin with Go Casbin
|
🎉 This PR is included in version 1.85.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds the missing
AddGroupingPoliciesExandAddNamedGroupingPoliciesExAPIs to sync jCasbin with Go Casbin implementation (commit ea5ed6b).Changes
New APIs in
ManagementEnforceraddGroupingPoliciesEx(List<List<String>> rules)- Adds grouping policies with default "g" ptypeaddGroupingPoliciesEx(String[][] rules)- Overload accepting String arrayaddNamedGroupingPoliciesEx(String ptype, List<List<String>> rules)- Named version with custom ptypeaddNamedGroupingPoliciesEx(String ptype, String[][] rules)- Named overload accepting String arrayThread-safe implementations in
SyncedEnforcerAll four methods are properly overridden with synchronization support using
runSynchronized().Motivation
The "Ex" variants provide more flexible policy management compared to the regular APIs:
Regular APIs (
addGroupingPolicies):Ex APIs (
addGroupingPoliciesEx):Example Usage
Testing
ManagementAPIUnitTestSyncedManagementAPIUnitTestFixes #459 (required by apache/casbin-jcasbin-postgres-watcher#3)
Original prompt
Fixes #461
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.