Skip to content

Commit f34f428

Browse files
authored
Merge pull request #4876 from cloudfoundry/userendpoints
Userendpoints
2 parents e8b0989 + 043140c commit f34f428

File tree

64 files changed

+2441
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2441
-186
lines changed

deploy/kubernetes/console/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The following table lists the configurable parameters of the Stratos Helm chart
7878
|console.userInviteSubject|Email subject of the user invitation message||
7979
|console.techPreview|Enable/disable Tech Preview features|false|
8080
|console.apiKeysEnabled|Enable/disable API key-based access to Stratos API (disabled, admin_only, all_users)|admin_only|
81+
|console.userEndpointsEnabled|Enable/disable user endpoints or let only admins view and manage user endpoints (disabled, admin_only, enabled)|disabled|
8182
|console.ui.listMaxSize|Override the default maximum number of entities that a configured list can fetch. When a list meets this amount additional pages are not fetched||
8283
|console.ui.listAllowLoadMaxed|If the maximum list size is met give the user the option to fetch all results|false|
8384
|console.localAdminPassword|Use local admin user instead of UAA - set to a password to enable||

deploy/kubernetes/console/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ spec:
288288
value: {{ default "false" .Values.console.techPreview | quote }}
289289
- name: API_KEYS_ENABLED
290290
value: {{ default "admin_only" .Values.console.apiKeysEnabled | quote }}
291+
- name: USER_ENDPOINTS_ENABLED
292+
value: {{ default "disabled" .Values.console.userEndpointsEnabled | quote }}
291293
- name: HELM_CACHE_FOLDER
292294
value: /helm-cache
293295
{{- if .Values.console.ui }}

deploy/kubernetes/console/values.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"enum": ["disabled", "admin_only", "all_users"],
1515
"description": "Enable API keys for admins, all users or nobody"
1616
},
17+
"userEndpointsEnabled": {
18+
"type": "string",
19+
"enum": ["disabled", "admin_only", "enabled"],
20+
"description": "Enable, disable or let only admins view and create user endpoints"
21+
},
1722
"autoRegisterCF": {
1823
"type": ["string", "null"]
1924
},

deploy/kubernetes/console/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ console:
7070
# Enable/disable API key-based access to Stratos API
7171
apiKeysEnabled: admin_only
7272

73+
# Enable/disable user endpoints
74+
userEndpointsEnabled: disabled
75+
7376
ui:
7477
# Override the default maximum number of entities that a configured list can fetch. When a list meets this amount additional pages are not fetched
7578
listMaxSize:

src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions-and-cfchecker.service.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ describe('CurrentUserPermissionsService with CF checker', () => {
6464
CfScopeStrings.CF_READ_SCOPE,
6565
]
6666
},
67+
creator: {
68+
name: 'admin',
69+
admin: true,
70+
system: false
71+
},
6772
metricsAvailable: false,
6873
connectionStatus: 'connected',
6974
system_shared_token: false,
@@ -102,6 +107,11 @@ describe('CurrentUserPermissionsService with CF checker', () => {
102107
StratosScopeStrings.SCIM_READ
103108
]
104109
},
110+
creator: {
111+
name: 'admin',
112+
admin: true,
113+
system: false
114+
},
105115
metricsAvailable: false,
106116
connectionStatus: 'connected',
107117
system_shared_token: false,

src/frontend/packages/core/src/core/endpoints.service.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createBasicStoreModule } from '@stratosui/store/testing';
33

44
import { PaginationMonitorFactory } from '../../../store/src/monitors/pagination-monitor.factory';
55
import { CoreTestingModule } from '../../test-framework/core-test.modules';
6+
import { SessionService } from '../shared/services/session.service';
67
import { CoreModule } from './core.module';
78
import { EndpointsService } from './endpoints.service';
89
import { UtilsService } from './utils.service';
@@ -13,7 +14,8 @@ describe('EndpointsService', () => {
1314
providers: [
1415
EndpointsService,
1516
UtilsService,
16-
PaginationMonitorFactory
17+
PaginationMonitorFactory,
18+
SessionService
1719
],
1820
imports: [
1921
CoreModule,

src/frontend/packages/core/src/core/endpoints.service.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { endpointEntitiesSelector, endpointStatusSelector } from '../../../store
1414
import { EndpointModel, EndpointState } from '../../../store/src/types/endpoint.types';
1515
import { IEndpointFavMetadata, UserFavorite } from '../../../store/src/types/user-favorites.types';
1616
import { endpointHasMetricsByAvailable } from '../features/endpoints/endpoint-helpers';
17+
import { SessionService } from '../shared/services/session.service';
1718
import { EndpointHealthChecks } from './endpoints-health-checks';
1819
import { UserService } from './user.service';
1920

@@ -50,7 +51,8 @@ export class EndpointsService implements CanActivate {
5051
constructor(
5152
private store: Store<EndpointOnlyAppState>,
5253
private userService: UserService,
53-
private endpointHealthChecks: EndpointHealthChecks
54+
private endpointHealthChecks: EndpointHealthChecks,
55+
private sessionService: SessionService
5456
) {
5557
this.endpoints$ = store.select(endpointEntitiesSelector);
5658
this.haveRegistered$ = this.endpoints$.pipe(map(endpoints => !!Object.keys(endpoints).length));
@@ -99,17 +101,19 @@ export class EndpointsService implements CanActivate {
99101
this.haveRegistered$,
100102
this.haveConnected$,
101103
this.userService.isAdmin$,
104+
this.userService.isEndpointAdmin$,
105+
this.sessionService.userEndpointsEnabled(),
102106
this.disablePersistenceFeatures$
103107
),
104-
map(([state, haveRegistered, haveConnected, isAdmin, disablePersistenceFeatures]
105-
: [[AuthState, EndpointState], boolean, boolean, boolean, boolean]) => {
108+
map(([state, haveRegistered, haveConnected, isAdmin, isEndpointAdmin, userEndpointsEnabled, disablePersistenceFeatures]
109+
: [[AuthState, EndpointState], boolean, boolean, boolean, boolean, boolean, boolean]) => {
106110
const [authState] = state;
107111
if (authState.sessionData.valid) {
108112
// Redirect to endpoints if there's no connected endpoints
109113
let redirect: string;
110114
if (!disablePersistenceFeatures) {
111115
if (!haveRegistered) {
112-
redirect = isAdmin ? '/endpoints' : '/noendpoints';
116+
redirect = isAdmin || (userEndpointsEnabled && isEndpointAdmin) ? '/endpoints' : '/noendpoints';
113117
} else if (!haveConnected) {
114118
redirect = '/endpoints';
115119
}

src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { UserFavoriteManager } from '../../../../store/src/user-favorite-manager
88
import { BaseTestModulesNoShared } from '../../../test-framework/core-test.helper';
99
import { ConfirmationDialogService } from '../../shared/components/confirmation-dialog.service';
1010
import { DialogConfirmComponent } from '../../shared/components/dialog-confirm/dialog-confirm.component';
11+
import { SessionService } from '../../shared/services/session.service';
1112
import { EntityFavoriteStarComponent } from './entity-favorite-star.component';
1213

1314
describe('EntityFavoriteStarComponent', () => {
@@ -28,7 +29,8 @@ describe('EntityFavoriteStarComponent', () => {
2829
overlayContainerElement = document.createElement('div');
2930
return { getContainerElement: () => overlayContainerElement };
3031
}
31-
}
32+
},
33+
SessionService
3234
],
3335
declarations: [
3436
DialogConfirmComponent

src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ describe('CurrentUserPermissionsService', () => {
5050
StratosScopeStrings.STRATOS_CHANGE_PASSWORD,
5151
]
5252
},
53+
creator: {
54+
name: 'admin',
55+
admin: true,
56+
system: false
57+
},
5358
metricsAvailable: false,
5459
connectionStatus: 'connected',
5560
system_shared_token: false,
@@ -83,6 +88,11 @@ describe('CurrentUserPermissionsService', () => {
8388
StratosScopeStrings.SCIM_READ
8489
]
8590
},
91+
creator: {
92+
name: 'admin',
93+
admin: true,
94+
system: false
95+
},
8696
metricsAvailable: false,
8797
connectionStatus: 'connected',
8898
system_shared_token: false,

src/frontend/packages/core/src/core/permissions/stratos-user-permissions.checker.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020

2121

2222
export enum StratosCurrentUserPermissions {
23-
ENDPOINT_REGISTER = 'register.endpoint',
23+
EDIT_ENDPOINT = 'edit-endpoint',
24+
EDIT_ADMIN_ENDPOINT = 'edit-admin-endpoint',
2425
PASSWORD_CHANGE = 'change-password',
2526
EDIT_PROFILE = 'edit-profile',
2627
/**
@@ -35,12 +36,12 @@ export enum StratosPermissionStrings {
3536
STRATOS_ADMIN = 'isAdmin'
3637
}
3738

38-
3939
export enum StratosScopeStrings {
4040
STRATOS_CHANGE_PASSWORD = 'password.write',
4141
SCIM_READ = 'scim.read',
4242
SCIM_WRITE = 'scim.write',
43-
STRATOS_NOAUTH = 'stratos.noauth'
43+
STRATOS_NOAUTH = 'stratos.noauth',
44+
STRATOS_ENDPOINTADMIN = 'stratos.endpointadmin'
4445
}
4546

4647
export enum StratosPermissionTypes {
@@ -53,7 +54,11 @@ export enum StratosPermissionTypes {
5354
// Every group result must be true in order for the permission to be true. A group result is true if all or some of it's permissions are
5455
// true (see `getCheckFromConfig`).
5556
export const stratosPermissionConfigs: IPermissionConfigs = {
56-
[StratosCurrentUserPermissions.ENDPOINT_REGISTER]: new PermissionConfig(
57+
[StratosCurrentUserPermissions.EDIT_ENDPOINT]: new PermissionConfig(
58+
StratosPermissionTypes.STRATOS_SCOPE,
59+
StratosScopeStrings.STRATOS_ENDPOINTADMIN
60+
),
61+
[StratosCurrentUserPermissions.EDIT_ADMIN_ENDPOINT]: new PermissionConfig(
5762
StratosPermissionTypes.STRATOS,
5863
StratosPermissionStrings.STRATOS_ADMIN
5964
),

0 commit comments

Comments
 (0)