Skip to content

Commit d4c0da1

Browse files
committed
add max_recursive_group_depth
1 parent ece8cf2 commit d4c0da1

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

OpenFlow/src/Config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export class Config {
157157
public static client_heartbeat_timeout: number = parseInt(Config.getEnv("client_heartbeat_timeout", "60"));
158158

159159
public static expected_max_roles: number = parseInt(Config.getEnv("expected_max_roles", "4000"));
160+
public static max_recursive_group_depth: number = parseInt(Config.getEnv("max_recursive_group_depth", "3"));
160161
public static update_acl_based_on_groups: boolean = Config.parseBoolean(Config.getEnv("update_acl_based_on_groups", "false"));
161162
public static multi_tenant: boolean = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));
162163
public static api_bypass_perm_check: boolean = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));

OpenFlow/src/DBHelper.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export class DBHelper {
4040
await this.DecorateWithRoles(result);
4141
return result;
4242
}
43-
public static async GetRoles(_id: string): Promise<Role[]> {
43+
public static async GetRoles(_id: string, ident: number): Promise<Role[]> {
44+
if (ident > Config.max_recursive_group_depth) return [];
4445
const result: Role[] = [];
4546
const query: any = { "members": { "$elemMatch": { _id: _id } } };
4647
const ids: string[] = [];
@@ -50,9 +51,11 @@ export class DBHelper {
5051
if (ids.indexOf(role._id) == -1) {
5152
ids.push(role._id);
5253
result.push(role);
53-
const _subroles: Role[] = await Config.db.query<Role>(query, null, Config.expected_max_roles, 0, null, "users", Crypt.rootToken());
54+
console.log(role.name + " " + role._id);
55+
const _subroles: Role[] = await this.GetRoles(role._id, ident + 1);
5456
for (let y = 0; y < _subroles.length; y++) {
5557
const subrole = _subroles[y];
58+
console.log(role.name + " " + subrole.name + " " + subrole._id);
5659
if (ids.indexOf(subrole._id) == -1) {
5760
ids.push(subrole._id);
5861
result.push(subrole);
@@ -63,7 +66,7 @@ export class DBHelper {
6366
return result;
6467
}
6568
public static async DecorateWithRoles(user: User): Promise<void> {
66-
const roles: Role[] = await this.GetRoles(user._id);
69+
const roles: Role[] = await this.GetRoles(user._id, 0);
6770
user.roles = [];
6871
roles.forEach(role => {
6972
user.roles.push(new Rolemember(role.name, role._id));

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/nodered",
3-
"version": "1.1.160",
3+
"version": "1.1.162",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.160
1+
1.1.162

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/openflow",
3-
"version": "1.1.160",
3+
"version": "1.1.162",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)