Skip to content

Commit 119138b

Browse files
committed
add toggle for entity restriction
1 parent 1fe50a3 commit 119138b

6 files changed

Lines changed: 12 additions & 4 deletions

File tree

OpenFlow/src/Config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class Config {
3030
Config.openflow_amqp_expiration = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min
3131
Config.amqp_prefetch = parseInt(Config.getEnv("amqp_prefetch", "50"));
3232
Config.trace_dashboardauth = Config.parseBoolean(Config.getEnv("trace_dashboardauth", "true"));
33+
Config.enable_entity_restriction = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false"));
3334

3435

3536
Config.getting_started_url = Config.getEnv("getting_started_url", "");
@@ -161,6 +162,7 @@ export class Config {
161162
public static openflow_amqp_expiration: number = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min
162163
public static amqp_prefetch: number = parseInt(Config.getEnv("amqp_prefetch", "50"));
163164
public static trace_dashboardauth: boolean = Config.parseBoolean(Config.getEnv("trace_dashboardauth", "true"));
165+
public static enable_entity_restriction: boolean = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false"));
164166

165167
public static getting_started_url: string = Config.getEnv("getting_started_url", "");
166168

OpenFlow/src/DatabaseConnection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,7 @@ export class DatabaseConnection {
20122012
}
20132013
public EntityRestrictions: EntityRestriction[] = null;
20142014
async CheckEntityRestriction(user: TokenUser, collection: string, item: Base, parent: Span): Promise<boolean> {
2015+
if (!Config.enable_entity_restriction) return true;
20152016
if (this.EntityRestrictions == null) {
20162017
const rootjwt = Crypt.rootToken()
20172018
this.EntityRestrictions = await this.query<EntityRestriction>({ "_type": "restriction" }, null, 1000, 0, null, "config", rootjwt, null, null, parent);

OpenFlow/src/LoginProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ export class LoginProvider {
417417
supports_watch: Config.supports_watch,
418418
nodered_images: Config.nodered_images,
419419
amqp_enabled_exchange: Config.amqp_enabled_exchange,
420-
multi_tenant: Config.multi_tenant
420+
multi_tenant: Config.multi_tenant,
421+
enable_entity_restriction: Config.enable_entity_restriction,
421422
}
422423
res.end(JSON.stringify(res2));
423424
} catch (error) {

OpenFlow/src/public/Nodered.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ <h1 translate lib="web">nodered</h1>
2424
ng-class="{disabled: !(ctrl.instance!=null && ctrl.instancestatus != 'pending deletion (Running)')}">Delete
2525
Nodered</button>
2626

27-
<a ng-href="{{ctrl.noderedurl}}" class="btn" ng-show="ctrl.instance!=null" target="_blank" rel="noopener">Open
27+
<a ng-href="{{ctrl.noderedurl}}" class="btn btn-success" ng-show="ctrl.instance!=null" target="_blank"
28+
rel="noopener">Open
2829
Nodered</a>
2930
</div>
3031
</div>

OpenFlow/src/public/WebSocketClientService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class WebSocketClientService {
3737
this.multi_tenant = data.multi_tenant;
3838

3939
this.nodered_images = data.nodered_images;
40+
this.enable_entity_restriction = data.enable_entity_restriction;
4041

4142
if (WebSocketClient.instance == null) {
4243
const cli: WebSocketClient = new WebSocketClient(this.logger, wsurl);
@@ -160,6 +161,7 @@ export class WebSocketClientService {
160161
public validate_user_form: string = "";
161162
public nodered_images: nodered_image[];
162163
public multi_tenant: boolean;
164+
public enable_entity_restriction: boolean;
163165

164166
getJSON(url: string, callback: any): void {
165167
const xhr: XMLHttpRequest = new XMLHttpRequest();

OpenFlow/src/public/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@
5858
translate lib="web">roles</span></a>
5959
<a class="dropdown-item" href="#/Credentials"><span translate lib="web">credentials</span></a>
6060
<a class="dropdown-item" href="#/Auditlogs"><span translate lib="web">auditlogs</span></a>
61-
<a class="dropdown-item" href="#/EntityRestrictions" ng-show="menuctrl.hasrole('admins')"><span translate
62-
lib="web">entityrestrictions</span></a>
61+
<a class="dropdown-item" href="#/EntityRestrictions"
62+
ng-show="menuctrl.WebSocketClientService.enable_entity_restriction && menuctrl.hasrole('admins')"><span
63+
translate lib="web">entityrestrictions</span></a>
6364
<a class="dropdown-item" href="#/Forms"><span translate lib="web">forms</span></a>
6465
<a class="dropdown-item" href="#/Providers" ng-show="menuctrl.hasrole('admins')"><span translate
6566
lib="web">providers</span></a>

0 commit comments

Comments
 (0)