forked from cloudfoundry/stratos
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df2a958
commit 619e9b3
Showing
13 changed files
with
99 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/frontend/packages/cloud-foundry/src/store/effects/roles.effects.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/frontend/packages/cloud-foundry/src/store/selectors/cloud-foundry.selector.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/frontend/packages/core/src/core/permissions/current-user-permissions.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { combineLatest, Observable, of } from 'rxjs'; | ||
import { distinctUntilChanged, map } from 'rxjs/operators'; | ||
|
||
import { PermissionConfig, PermissionConfigType, PermissionTypes } from './current-user-permissions.config'; | ||
|
||
export interface IConfigGroups { | ||
[permissionType: string]: IConfigGroup; | ||
} | ||
|
||
export type IConfigGroup = PermissionConfig[]; | ||
|
||
export type IPermissionCheckCombineTypes = '||' | '&&'; | ||
|
||
export interface IPermissionCheckCombiner { | ||
checks: Observable<boolean>[]; | ||
combineType?: IPermissionCheckCombineTypes; | ||
} | ||
export interface ICurrentUserPermissionsChecker { | ||
/** | ||
* For the given permission action find the checker configuration that will determine if the user can or cannot do the action | ||
* If this is not supported by the the checker null is returned. If another checker also lays claim to the same string the check will | ||
* always return denied | ||
*/ | ||
getPermissionConfig: (action: string) => PermissionConfigType | ||
/** | ||
* Simple checks are used when the permission config contains a single thing to check | ||
*/ | ||
getSimpleCheck: ( | ||
permissionConfig: PermissionConfig, | ||
endpointGuid?: string, | ||
...args: any[] | ||
) => Observable<boolean>; | ||
/** | ||
* Used when the permission config contains multiple things to check | ||
*/ | ||
getComplexCheck: ( | ||
permissionConfig: PermissionConfig[], | ||
permission: PermissionTypes, | ||
...args: any[] | ||
) => IPermissionCheckCombiner[]; | ||
/** | ||
* If no checker provides simple | ||
*/ | ||
getFallbackCheck: ( | ||
endpointGuid: string, | ||
endpointType: string | ||
) => Observable<boolean>; | ||
} | ||
|
||
export abstract class BaseCurrentUserPermissionsChecker { | ||
public static reduceChecks(checks: Observable<boolean>[], type: IPermissionCheckCombineTypes = '||') { | ||
const func = type === '||' ? 'some' : 'every'; | ||
if (!checks || !checks.length) { | ||
return of(true); | ||
} | ||
return combineLatest(checks).pipe( | ||
map(flags => flags[func](flag => flag)), | ||
distinctUntilChanged() | ||
); | ||
} | ||
} |
72 changes: 7 additions & 65 deletions
72
src/frontend/packages/core/src/core/permissions/stratos-user-permissions.checker.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters