Comparing version 5.22.0 to 5.23.0
@@ -0,1 +1,8 @@ | ||
# [5.23.0](https://github.com/casbin/node-casbin/compare/v5.22.0...v5.23.0) (2023-02-01) | ||
### Features | ||
* support `updateGroupingPolicy()`, `updateNamedGroupingPolicy()`, `getImplicitResourcesForUser()` ([#419](https://github.com/casbin/node-casbin/issues/419)) ([46c0f3a](https://github.com/casbin/node-casbin/commit/46c0f3ad09c4e8cf673d9d9b9b8fcf00251caaaf)) | ||
# [5.22.0](https://github.com/casbin/node-casbin/compare/v5.21.0...v5.22.0) (2023-01-31) | ||
@@ -2,0 +9,0 @@ |
@@ -179,2 +179,6 @@ import { ManagementEnforcer } from './managementEnforcer'; | ||
/** | ||
* getImplicitResourcesForUser returns all policies that user obtaining in domain. | ||
*/ | ||
getImplicitResourcesForUser(user: string, ...domain: string[]): Promise<string[][]>; | ||
/** | ||
* getImplicitUsersForRole gets implicit users that a role has. | ||
@@ -181,0 +185,0 @@ * Compared to getUsersForRole(), this function retrieves indirect users besides direct users. |
@@ -330,2 +330,39 @@ "use strict"; | ||
/** | ||
* getImplicitResourcesForUser returns all policies that user obtaining in domain. | ||
*/ | ||
async getImplicitResourcesForUser(user, ...domain) { | ||
const permissions = await this.getImplicitPermissionsForUser(user, ...domain); | ||
const res = []; | ||
for (const permission of permissions) { | ||
if (permission[0] === user) { | ||
res.push(permission); | ||
continue; | ||
} | ||
let resLocal = [[user]]; | ||
const tokensLength = permission.length; | ||
const t = []; | ||
for (const token of permission) { | ||
if (token === permission[0]) { | ||
continue; | ||
} | ||
const tokens = await this.getImplicitUsersForRole(token, ...domain); | ||
tokens.push(token); | ||
t.push(tokens); | ||
} | ||
for (let i = 0; i < tokensLength - 1; i++) { | ||
const n = []; | ||
for (const tokens of t[i]) { | ||
for (const policy of resLocal) { | ||
const t = [...policy]; | ||
t.push(tokens); | ||
n.push(t); | ||
} | ||
} | ||
resLocal = n; | ||
} | ||
res.push(...resLocal); | ||
} | ||
return res; | ||
} | ||
/** | ||
* getImplicitUsersForRole gets implicit users that a role has. | ||
@@ -332,0 +369,0 @@ * Compared to getUsersForRole(), this function retrieves indirect users besides direct users. |
@@ -371,2 +371,19 @@ import { InternalEnforcer } from './internalEnforcer'; | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateGroupingPolicy(oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateNamedGroupingPolicy(ptype: string, oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* addFunction adds a customized function. | ||
@@ -373,0 +390,0 @@ * @param name custom function name |
@@ -470,2 +470,23 @@ "use strict"; | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateGroupingPolicy(oldRule, newRule) { | ||
return this.updateNamedGroupingPolicy('g', oldRule, newRule); | ||
} | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateNamedGroupingPolicy(ptype, oldRule, newRule) { | ||
return this.updatePolicyInternal('g', ptype, oldRule, newRule, true); | ||
} | ||
/** | ||
* addFunction adds a customized function. | ||
@@ -472,0 +493,0 @@ * @param name custom function name |
@@ -323,2 +323,19 @@ import { Enforcer } from './enforcer'; | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateGroupingPolicy(oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateNamedGroupingPolicy(ptype: string, oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* add matching function to RoleManager by ptype | ||
@@ -325,0 +342,0 @@ * @param ptype g |
@@ -447,2 +447,23 @@ "use strict"; | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateGroupingPolicy(oldRule, newRule) { | ||
return super.updateGroupingPolicy(oldRule, newRule); | ||
} | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateNamedGroupingPolicy(ptype, oldRule, newRule) { | ||
return super.updateNamedGroupingPolicy(ptype, oldRule, newRule); | ||
} | ||
/** | ||
* add matching function to RoleManager by ptype | ||
@@ -449,0 +470,0 @@ * @param ptype g |
@@ -179,2 +179,6 @@ import { ManagementEnforcer } from './managementEnforcer'; | ||
/** | ||
* getImplicitResourcesForUser returns all policies that user obtaining in domain. | ||
*/ | ||
getImplicitResourcesForUser(user: string, ...domain: string[]): Promise<string[][]>; | ||
/** | ||
* getImplicitUsersForRole gets implicit users that a role has. | ||
@@ -181,0 +185,0 @@ * Compared to getUsersForRole(), this function retrieves indirect users besides direct users. |
@@ -327,2 +327,39 @@ // Copyright 2018 The Casbin Authors. All Rights Reserved. | ||
/** | ||
* getImplicitResourcesForUser returns all policies that user obtaining in domain. | ||
*/ | ||
async getImplicitResourcesForUser(user, ...domain) { | ||
const permissions = await this.getImplicitPermissionsForUser(user, ...domain); | ||
const res = []; | ||
for (const permission of permissions) { | ||
if (permission[0] === user) { | ||
res.push(permission); | ||
continue; | ||
} | ||
let resLocal = [[user]]; | ||
const tokensLength = permission.length; | ||
const t = []; | ||
for (const token of permission) { | ||
if (token === permission[0]) { | ||
continue; | ||
} | ||
const tokens = await this.getImplicitUsersForRole(token, ...domain); | ||
tokens.push(token); | ||
t.push(tokens); | ||
} | ||
for (let i = 0; i < tokensLength - 1; i++) { | ||
const n = []; | ||
for (const tokens of t[i]) { | ||
for (const policy of resLocal) { | ||
const t = [...policy]; | ||
t.push(tokens); | ||
n.push(t); | ||
} | ||
} | ||
resLocal = n; | ||
} | ||
res.push(...resLocal); | ||
} | ||
return res; | ||
} | ||
/** | ||
* getImplicitUsersForRole gets implicit users that a role has. | ||
@@ -329,0 +366,0 @@ * Compared to getUsersForRole(), this function retrieves indirect users besides direct users. |
@@ -371,2 +371,19 @@ import { InternalEnforcer } from './internalEnforcer'; | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateGroupingPolicy(oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateNamedGroupingPolicy(ptype: string, oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* addFunction adds a customized function. | ||
@@ -373,0 +390,0 @@ * @param name custom function name |
@@ -467,2 +467,23 @@ // Copyright 2018 The Casbin Authors. All Rights Reserved. | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateGroupingPolicy(oldRule, newRule) { | ||
return this.updateNamedGroupingPolicy('g', oldRule, newRule); | ||
} | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateNamedGroupingPolicy(ptype, oldRule, newRule) { | ||
return this.updatePolicyInternal('g', ptype, oldRule, newRule, true); | ||
} | ||
/** | ||
* addFunction adds a customized function. | ||
@@ -469,0 +490,0 @@ * @param name custom function name |
@@ -323,2 +323,19 @@ import { Enforcer } from './enforcer'; | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateGroupingPolicy(oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
updateNamedGroupingPolicy(ptype: string, oldRule: string[], newRule: string[]): Promise<boolean>; | ||
/** | ||
* add matching function to RoleManager by ptype | ||
@@ -325,0 +342,0 @@ * @param ptype g |
@@ -441,2 +441,23 @@ // Copyright 2020 The Casbin Authors. All Rights Reserved. | ||
/** | ||
* UpdateGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateGroupingPolicy(oldRule, newRule) { | ||
return super.updateGroupingPolicy(oldRule, newRule); | ||
} | ||
/** | ||
* updateNamedGroupingPolicy updates an rule to the current named policy. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the old rule. | ||
* @param newRule the new rule. | ||
* @return succeeds or not. | ||
*/ | ||
async updateNamedGroupingPolicy(ptype, oldRule, newRule) { | ||
return super.updateNamedGroupingPolicy(ptype, oldRule, newRule); | ||
} | ||
/** | ||
* add matching function to RoleManager by ptype | ||
@@ -443,0 +464,0 @@ * @param ptype g |
{ | ||
"name": "casbin", | ||
"version": "5.22.0", | ||
"version": "5.23.0", | ||
"description": "An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS", | ||
@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
593268
13949