diff --git a/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.html b/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.html
index 0775265f9d..facd9c4be7 100644
--- a/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.html
+++ b/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.html
@@ -5,7 +5,7 @@
Endpoints
[routerLink]="'/endpoints/new/'" matTooltip="Register Endpoint">
add
-
diff --git a/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.ts b/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.ts
index 9ecf211ded..7904575755 100644
--- a/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.ts
+++ b/src/frontend/packages/core/src/features/endpoints/endpoints-page/endpoints-page.component.ts
@@ -11,11 +11,12 @@ import {
ViewContainerRef,
} from '@angular/core';
import { Store } from '@ngrx/store';
-import { combineLatest, Subscription } from 'rxjs';
-import { delay, first, map, tap } from 'rxjs/operators';
+import { combineLatest, Observable, of, Subscription } from 'rxjs';
+import { delay, first, map, switchMap, tap } from 'rxjs/operators';
import { RouterNav } from '../../../../../store/src/actions/router.actions';
import { EndpointOnlyAppState } from '../../../../../store/src/app-state';
+import { selectSessionData } from '../../../../../store/src/reducers/auth.reducer';
import { selectDashboardState } from '../../../../../store/src/selectors/dashboard.selectors';
import { CustomizationService, CustomizationsMetadata } from '../../../core/customizations.types';
import { EndpointsService } from '../../../core/endpoints.service';
@@ -24,6 +25,7 @@ import {
StratosActionMetadata,
StratosActionType,
} from '../../../core/extension/extension-service';
+import { CurrentUserPermissionsService } from '../../../core/permissions/current-user-permissions.service';
import { StratosCurrentUserPermissions } from '../../../core/permissions/stratos-user-permissions.checker';
import { safeUnsubscribe } from '../../../core/utils.service';
import { EndpointListHelper } from '../../../shared/components/list/list-types/endpoint/endpoint-list.helpers';
@@ -46,6 +48,8 @@ export class EndpointsPageComponent implements AfterViewInit, OnDestroy, OnInit
public canRegisterEndpoint = StratosCurrentUserPermissions.ENDPOINT_REGISTER;
private healthCheckTimeout: number;
+ public canBackupRestore$: Observable;
+
@ViewChild('customNoEndpoints', { read: ViewContainerRef, static: true }) customNoEndpointsContainer;
customContentComponentRef: ComponentRef;
@@ -62,7 +66,8 @@ export class EndpointsPageComponent implements AfterViewInit, OnDestroy, OnInit
private ngZone: NgZone,
private resolver: ComponentFactoryResolver,
private snackBarService: SnackBarService,
- cs: CustomizationService
+ cs: CustomizationService,
+ currentUserPermissionsService: CurrentUserPermissionsService,
) {
this.customizations = cs.get();
@@ -81,6 +86,13 @@ export class EndpointsPageComponent implements AfterViewInit, OnDestroy, OnInit
}),
first()
).subscribe();
+
+ // Is the backup/restore plugin available on the backend?
+ this.canBackupRestore$ = this.store.select(selectSessionData()).pipe(
+ first(),
+ map(sessionData => sessionData?.plugins.backup),
+ switchMap(enabled => enabled ? currentUserPermissionsService.can(this.canRegisterEndpoint) : of(false))
+ );
}
subs: Subscription[] = [];
diff --git a/src/jetstream/config.example b/src/jetstream/config.example
index 19441c990e..8b0b0ed4b7 100644
--- a/src/jetstream/config.example
+++ b/src/jetstream/config.example
@@ -80,3 +80,6 @@ INVITE_USER_CLIENT_SECRET=
# Enabled Artifact Hub
# ARTIFACT_HUB_DISABLED=false
+
+# Allow backup/restore feature?
+#FEATURE_ALLOW_BACKUP=false
diff --git a/src/jetstream/plugins/backup/main.go b/src/jetstream/plugins/backup/main.go
index 40082086ef..72d23b4833 100644
--- a/src/jetstream/plugins/backup/main.go
+++ b/src/jetstream/plugins/backup/main.go
@@ -4,6 +4,7 @@ import (
"database/sql"
"errors"
"net/http"
+ "strconv"
goosedbversion "github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/goose-db-version"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/interfaces"
@@ -21,7 +22,7 @@ type BackupRestore struct {
portalProxy interfaces.PortalProxy
}
-// Init creates a new Autoscaler
+// Init creates a new backup/restore plugin
func Init(portalProxy interfaces.PortalProxy) (interfaces.StratosPlugin, error) {
return &BackupRestore{portalProxy: portalProxy}, nil
}
@@ -54,6 +55,11 @@ func (br *BackupRestore) AddSessionGroupRoutes(echoGroup *echo.Group) {
// Init performs plugin initialization
func (br *BackupRestore) Init() error {
+ enabledStr := br.portalProxy.Env().String("FEATURE_ALLOW_BACKUP", "true")
+ if enabled, err := strconv.ParseBool(enabledStr); err == nil && !enabled {
+ return errors.New("Backup/restoure feature disabled via configuration")
+ }
+
return nil
}