From 46bb9bd613ec48a4b3d1e59eb4e5de3dd7d03962 Mon Sep 17 00:00:00 2001 From: Wroud Date: Thu, 13 Aug 2020 18:52:26 +0300 Subject: [PATCH] feat(core): connections access managment CB-232 --- .../packages/core-authentication/.gitignore | 21 ++++ .../packages/core-authentication/package.json | 24 +++++ .../src/AuthInfoService.ts | 0 .../src/AuthProviderService.ts | 0 .../src/AuthProvidersResource.ts | 0 .../src}/RolesManagerService.ts | 0 .../src}/RolesResource.ts | 0 .../src}/UsersResource.ts | 8 +- .../packages/core-authentication/src/index.ts | 6 ++ .../core-authentication/tsconfig.json | 10 ++ webapp/packages/core-bootstrap/package.json | 1 + .../packages/core-bootstrap/src/manifest.ts | 9 ++ webapp/packages/core-connections/package.json | 2 + .../ConnectionsTable/ConnectionEdit.tsx | 18 ++++ .../ConnectionEditController.ts | 58 ++++++++++- .../ConnectionsTable/GrantedSubjects.tsx | 97 +++++++++++++++++++ .../src/Administration/ConnectionsResource.ts | 15 +++ .../core-connections/src/locales/en.ts | 3 + .../core-connections/src/locales/ru.ts | 3 + .../administration/getConnectionAccess.gql | 7 ++ .../administration/setConnectionAccess.gql | 3 + webapp/packages/core-sdk/src/sdk.ts | 33 +++++++ .../plugin-authentication/package.json | 1 + .../Users/UsersAdministrationController.ts | 3 +- .../Users/UsersAdministrationService.ts | 2 +- .../Administration/Users/UsersTable/User.tsx | 2 +- .../Users/UsersTable/UserEdit.tsx | 2 +- .../Users/UsersTable/UserEditController.ts | 4 +- .../src/AuthMenuService.ts | 2 +- .../src/AuthenticationService.ts | 2 +- .../src/Dialog/AuthDialogController.ts | 4 +- .../AuthProviderForm/AuthProviderForm.tsx | 2 +- .../plugin-authentication/src/UserInfo.tsx | 3 +- .../plugin-authentication/src/index.ts | 3 - .../plugin-authentication/src/manifest.ts | 12 --- 35 files changed, 326 insertions(+), 34 deletions(-) create mode 100644 webapp/packages/core-authentication/.gitignore create mode 100644 webapp/packages/core-authentication/package.json rename webapp/packages/{plugin-authentication => core-authentication}/src/AuthInfoService.ts (100%) rename webapp/packages/{plugin-authentication => core-authentication}/src/AuthProviderService.ts (100%) rename webapp/packages/{plugin-authentication => core-authentication}/src/AuthProvidersResource.ts (100%) rename webapp/packages/{plugin-authentication/src/Administration => core-authentication/src}/RolesManagerService.ts (100%) rename webapp/packages/{plugin-authentication/src/Administration => core-authentication/src}/RolesResource.ts (100%) rename webapp/packages/{plugin-authentication/src/Administration => core-authentication/src}/UsersResource.ts (96%) create mode 100644 webapp/packages/core-authentication/src/index.ts create mode 100644 webapp/packages/core-authentication/tsconfig.json create mode 100644 webapp/packages/core-connections/src/Administration/Connections/ConnectionsTable/GrantedSubjects.tsx create mode 100644 webapp/packages/core-sdk/src/queries/connections/administration/getConnectionAccess.gql create mode 100644 webapp/packages/core-sdk/src/queries/connections/administration/setConnectionAccess.gql diff --git a/webapp/packages/core-authentication/.gitignore b/webapp/packages/core-authentication/.gitignore new file mode 100644 index 0000000000..99902db863 --- /dev/null +++ b/webapp/packages/core-authentication/.gitignore @@ -0,0 +1,21 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/lib + +# misc +.DS_Store +.env* + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/webapp/packages/core-authentication/package.json b/webapp/packages/core-authentication/package.json new file mode 100644 index 0000000000..8c5350318e --- /dev/null +++ b/webapp/packages/core-authentication/package.json @@ -0,0 +1,24 @@ +{ + "name": "@cloudbeaver/core-authentication", + "sideEffects": false, + "version": "0.1.0", + "description": "", + "license": "Apache-2.0", + "main": "lib/index.js", + "module": "lib/index.js", + "scripts": { + "prebuild": "rimraf lib/*", + "build": "webpack --config ../../configs/webpack.plugin.config", + "postbuild": "tsc", + "lint": "eslint ./src/ --ext .ts,.tsx", + "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix" + }, + "peerDependencies": { + "@cloudbeaver/core-di": "^0.1.0", + "@cloudbeaver/core-events": "^0.1.0", + "@cloudbeaver/core-root": "^0.1.0", + "@cloudbeaver/core-sdk": "^0.1.0", + "@cloudbeaver/core-utils": "^0.1.0", + "mobx": "^5.x.x" + } +} \ No newline at end of file diff --git a/webapp/packages/plugin-authentication/src/AuthInfoService.ts b/webapp/packages/core-authentication/src/AuthInfoService.ts similarity index 100% rename from webapp/packages/plugin-authentication/src/AuthInfoService.ts rename to webapp/packages/core-authentication/src/AuthInfoService.ts diff --git a/webapp/packages/plugin-authentication/src/AuthProviderService.ts b/webapp/packages/core-authentication/src/AuthProviderService.ts similarity index 100% rename from webapp/packages/plugin-authentication/src/AuthProviderService.ts rename to webapp/packages/core-authentication/src/AuthProviderService.ts diff --git a/webapp/packages/plugin-authentication/src/AuthProvidersResource.ts b/webapp/packages/core-authentication/src/AuthProvidersResource.ts similarity index 100% rename from webapp/packages/plugin-authentication/src/AuthProvidersResource.ts rename to webapp/packages/core-authentication/src/AuthProvidersResource.ts diff --git a/webapp/packages/plugin-authentication/src/Administration/RolesManagerService.ts b/webapp/packages/core-authentication/src/RolesManagerService.ts similarity index 100% rename from webapp/packages/plugin-authentication/src/Administration/RolesManagerService.ts rename to webapp/packages/core-authentication/src/RolesManagerService.ts diff --git a/webapp/packages/plugin-authentication/src/Administration/RolesResource.ts b/webapp/packages/core-authentication/src/RolesResource.ts similarity index 100% rename from webapp/packages/plugin-authentication/src/Administration/RolesResource.ts rename to webapp/packages/core-authentication/src/RolesResource.ts diff --git a/webapp/packages/plugin-authentication/src/Administration/UsersResource.ts b/webapp/packages/core-authentication/src/UsersResource.ts similarity index 96% rename from webapp/packages/plugin-authentication/src/Administration/UsersResource.ts rename to webapp/packages/core-authentication/src/UsersResource.ts index b0426d6c6f..050b73b360 100644 --- a/webapp/packages/plugin-authentication/src/Administration/UsersResource.ts +++ b/webapp/packages/core-authentication/src/UsersResource.ts @@ -17,8 +17,8 @@ import { } from '@cloudbeaver/core-sdk'; import { MetadataMap, uuid } from '@cloudbeaver/core-utils'; -import { AuthInfoService } from '../AuthInfoService'; -import { AuthProviderService } from '../AuthProviderService'; +import { AuthInfoService } from './AuthInfoService'; +import { AuthProviderService } from './AuthProviderService'; const NEW_USER_SYMBOL = Symbol('new-user'); @@ -76,6 +76,10 @@ export class UsersResource extends CachedMapResource { } async loadConnections(userId: string): Promise { + if (this.isNew(userId)) { + return []; + } + const { grantedConnections } = await this.graphQLService.gql.getUserGrantedConnections({ userId }); return grantedConnections; diff --git a/webapp/packages/core-authentication/src/index.ts b/webapp/packages/core-authentication/src/index.ts new file mode 100644 index 0000000000..a5234cb6b3 --- /dev/null +++ b/webapp/packages/core-authentication/src/index.ts @@ -0,0 +1,6 @@ +export * from './AuthInfoService'; +export * from './AuthProviderService'; +export * from './AuthProvidersResource'; +export * from './RolesManagerService'; +export * from './RolesResource'; +export * from './UsersResource'; diff --git a/webapp/packages/core-authentication/tsconfig.json b/webapp/packages/core-authentication/tsconfig.json new file mode 100644 index 0000000000..b0b5e9edfa --- /dev/null +++ b/webapp/packages/core-authentication/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "lib" + }, + "exclude": [ + "node_modules" + ], + "include": ["src/**/*"] +} diff --git a/webapp/packages/core-bootstrap/package.json b/webapp/packages/core-bootstrap/package.json index 9464583915..0ba9946b99 100644 --- a/webapp/packages/core-bootstrap/package.json +++ b/webapp/packages/core-bootstrap/package.json @@ -16,6 +16,7 @@ "dependencies": { "@cloudbeaver/core-administration": "^0.1.0", "@cloudbeaver/core-app": "^0.1.0", + "@cloudbeaver/core-authentication": "^0.1.0", "@cloudbeaver/core-blocks": "^0.1.0", "@cloudbeaver/core-connections": "^0.1.0", "@cloudbeaver/core-di": "^0.1.0", diff --git a/webapp/packages/core-bootstrap/src/manifest.ts b/webapp/packages/core-bootstrap/src/manifest.ts index 99929c8294..fb93fe6ae2 100644 --- a/webapp/packages/core-bootstrap/src/manifest.ts +++ b/webapp/packages/core-bootstrap/src/manifest.ts @@ -21,6 +21,9 @@ import { SettingsMenuService, LogViewerService, LogViewerMenuService, TopNavService, AppScreenService, CoreSettingsService, AdministrationTopAppBarBootstrapService } from '@cloudbeaver/core-app'; +import { + AuthInfoService, AuthProviderService, AuthProvidersResource, RolesManagerService, RolesResource, UsersResource +} from '@cloudbeaver/core-authentication'; import { ConnectionsManagerService, ConnectionInfoResource, @@ -71,6 +74,12 @@ export const coreManifest: PluginManifest = { ProductSettingsService, ProductManagerService, PluginManagerService, + AuthInfoService, + AuthProviderService, + AuthProvidersResource, + RolesManagerService, + RolesResource, + UsersResource, ServerSettingsService, ServerConfigResource, PermissionsResource, diff --git a/webapp/packages/core-connections/package.json b/webapp/packages/core-connections/package.json index 99a88947fa..19a865c328 100644 --- a/webapp/packages/core-connections/package.json +++ b/webapp/packages/core-connections/package.json @@ -14,6 +14,8 @@ "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix" }, "peerDependencies": { + "@cloudbeaver/core-administration": "^0.1.0", + "@cloudbeaver/core-authentication": "^0.1.0", "@cloudbeaver/core-di": "^0.1.0", "@cloudbeaver/core-plugin": "^0.1.0", "@cloudbeaver/core-localization": "^0.1.0", diff --git a/webapp/packages/core-connections/src/Administration/Connections/ConnectionsTable/ConnectionEdit.tsx b/webapp/packages/core-connections/src/Administration/Connections/ConnectionsTable/ConnectionEdit.tsx index ecc04c9736..e711d3a610 100644 --- a/webapp/packages/core-connections/src/Administration/Connections/ConnectionsTable/ConnectionEdit.tsx +++ b/webapp/packages/core-connections/src/Administration/Connections/ConnectionsTable/ConnectionEdit.tsx @@ -24,6 +24,7 @@ import { ConnectionsResource } from '../../ConnectionsResource'; import { ConnectionEditController } from './ConnectionEditController'; import { ConnectionForm } from './ConnectionForm/ConnectionForm'; import { DriverProperties } from './DriverProperties/DriverProperties'; +import { GrantedSubjects } from './GrantedSubjects'; const styles = composes( css` @@ -42,6 +43,10 @@ const styles = composes( SubmittingForm { composes: theme-background-secondary from global; } + + GrantedSubjects { + composes: theme-background-surface from global; + } `, css` custom-connection { @@ -143,6 +148,9 @@ export const ConnectionEdit = observer(function ConnectionEdit({ setLoadProperties(true)} disabled={!controller.driver} > {translate('customConnection_properties')} + + {translate('connections_connection_edit_access')} +