Skip to content

Commit

Permalink
feat: sync conditional roles to regular roles to fix ConditionalRoleM…
Browse files Browse the repository at this point in the history
…anager bug (#410)

* feat:synchronize conditional roles to regular roles

* feat:synchronize the rmMap
  • Loading branch information
liewstar committed Jul 27, 2024
1 parent bab3550 commit 6776f75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/casbin/jcasbin/main/CoreEnforcer.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ private void initRmMap() {
if (token_length <= 2 && paramsToken_length != 0) {
assertion.condRM =new ConditionalRoleManager(10);
condRmMap.put(ptype, assertion.condRM);
rmMap.put(ptype, assertion.condRM);
}
if (token_length > 2) {
if (paramsToken_length == 0) {
Expand All @@ -396,6 +397,7 @@ private void initRmMap() {
} else {
assertion.condRM = new ConditionalRoleManager(10);
condRmMap.put(ptype, assertion.condRM);
rmMap.put(ptype, assertion.condRM);
}
String matchFun = "keyMatch(r_dom, p_dom)";
if (model.model.get("m").get("m").value.contains(matchFun)) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/casbin/jcasbin/model/Assertion.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ public void addConditionalRoleLink(List<String> rule, List<String> domainRule){
if (domainRule_num == 0){
condRM.addLink(rule.get(0), rule.get(1));
condRM.setLinkConditionFuncParams(rule.get(0), rule.get(1), rule.subList(tokens.length, rule.size()).toArray(new String[0]));
rm = condRM;
}else {
String domain = domainRule.get(0);
condRM.addLink(rule.get(0), rule.get(1));
condRM.setDomainLinkConditionFuncParams(rule.get(0), rule.get(1), domain, rule.subList(tokens.length, rule.size()).toArray(new String[0]));
rm = condRM;
}
}

Expand Down

0 comments on commit 6776f75

Please sign in to comment.