From 2ee3edee584bb4a92703e7cd1fb3b994c0262dff Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 1 May 2024 11:39:22 +0530 Subject: [PATCH] Nc feat/user management (#8369) * fix: source filter Signed-off-by: mertmit * feat: sso cloud apis - WIP * feat: admin panel menu option * feat: UI integration - WIP * feat: UI integration - SSO * feat: domain verification * feat: workspace upgrade and sso page - WIP * feat: domain adding and verification - WIP * feat: domain adding and verification * fix: domain validation corrections * chore: lint * feat(nc-gui): organization settings page * feat(nc-gui): organization members page * fix(nc-gui): some more changes * fix(nc-gui): refactor collaborators ui * feat(nc-gui): dashboard ui * feat(nc-gui): bases page * feat(nocodb): wired up ui and apis. wip * fix(nc-gui): some more fixes * fix(nc-gui): move ws to org immediately after creation * fix(nc-gui): some more bug fixes * feat(nocodb): transfer workspace ownership * fix(nc-gui): load roles if baseId is provided in prop * fix(nc-gui): show only org workspaces * fix(nc-gui): some more fixes * fix(nc-gui): rename base * fix(nc-gui): invite fixes * feat: restrict access to org level user(SSO login) * fix: include org and client info in token * fix: include org and client info in refresh token * refactor: minor ui corrections * refactor: add a generic component for copying * refactor: ui correction and cleanup * fix: refresh token update * fix: ui corrections * fix: if user signin using unverified domain show error in sso page rather than showing the json with error * fix: for all sso related exceptions redirect to sso ui page with error * chore: lint * fix: show admin panel option only for user who have permission * fix: redirect to sso login page on logout based on current user info * test: sso - playwright test * fix: duplicate attribute * test: playwright * fix: missing import * test: playwright - WIP * test: playwright - Cloud sso login flow * fix: error handling * test: playwright - sso auth flow tests * fix: show upgrade option only for workspace owner * test: user invite tests corrections * test: user invite tests corrections * test: user management correction * test: playwright - use regex for path match * fix: delete existing provider if any * test: combine sso tests to run serially * test: playwright - title name correction * test: playwright - reset sso client from sso tests only * test: playwright - page navigation correction * refactor: by default navigate to org settings page on org creation and disable org image upload * refactor: reverify domain after 7 days and update role names to avoid confusion between org and cloud org roles * fix: corrections * fix: show org level roles in members section * refactor: disable org update by default * test: unit tests for org admin apis * chore: lint * fix: review comments * chore: lint and cleanup --------- Signed-off-by: mertmit Co-authored-by: mertmit Co-authored-by: DarkPhoenix2704 --- .../nc-gui/assets/nc-icons/arrow-up-right.svg | 4 + .../nc-gui/assets/nc-icons/control-panel.svg | 5 + packages/nc-gui/assets/nc-icons/home.svg | 4 + packages/nc-gui/assets/nc-icons/office.svg | 10 + packages/nc-gui/assets/nc-icons/slash.svg | 11 + packages/nc-gui/assets/nc-icons/workspace.svg | 4 + packages/nc-gui/components.d.ts | 1 + .../dashboard/Sidebar/EEMenuOption.vue | 3 + .../components/dashboard/Sidebar/UserInfo.vue | 6 +- .../dashboard/settings/DataSources.vue | 4 +- .../settings/data-sources/CreateBase.vue | 3 +- .../ShareBaseDlg.vue => dlg/InviteDlg.vue} | 208 +++++++++++++----- .../general/BaseIconColorPicker.vue | 3 +- .../nc-gui/components/general/CopyButton.vue | 26 +++ .../components/general/WorkspaceIcon.vue | 2 + packages/nc-gui/components/nc/Badge.vue | 7 +- .../nc-gui/components/nc/ErrorBoundary.vue | 2 +- packages/nc-gui/components/nc/Select.vue | 2 + .../components/project/AccessSettings.vue | 128 +++++++---- packages/nc-gui/components/project/View.vue | 48 ++-- packages/nc-gui/components/roles/Badge.vue | 8 +- packages/nc-gui/components/roles/Selector.vue | 8 +- .../smartsheet/expanded-form/Comments.vue | 4 +- .../smartsheet/toolbar/CreateGroupBy.vue | 2 - .../workspace/CollaboratorsList.vue | 184 +++++++++++----- .../nc-gui/components/workspace/Settings.vue | 40 ++-- packages/nc-gui/components/workspace/View.vue | 91 ++++++-- .../nc-gui/composables/useOrganization.ts | 23 ++ packages/nc-gui/composables/useUserSorts.ts | 11 +- packages/nc-gui/context/index.ts | 2 + packages/nc-gui/lang/en.json | 68 ++++++ packages/nc-gui/lib/acl.ts | 1 + packages/nc-gui/lib/types.ts | 2 +- packages/nc-gui/middleware/02.auth.global.ts | 18 ++ packages/nc-gui/store/workspace.ts | 5 +- packages/nc-gui/utils/datetimeUtils.ts | 28 +++ packages/nc-gui/utils/iconUtils.ts | 12 + packages/nc-gui/utils/index.ts | 1 + packages/nocodb-sdk/src/lib/Api.ts | 193 +++++++++++++++- packages/nocodb-sdk/src/lib/enums.ts | 16 ++ .../global-exception.filter.ts | 21 ++ packages/nocodb/src/helpers/catchError.ts | 9 + .../extract-ids/extract-ids.middleware.ts | 2 +- .../nocodb/src/models/UserRefreshToken.ts | 2 +- packages/nocodb/src/services/users/helpers.ts | 6 +- .../authtoken.strategy/authtoken.strategy.ts | 3 + packages/nocodb/tests/unit/rest/index.test.ts | 3 + .../pages/Account/Authentication.ts | 12 +- tests/playwright/pages/Base.ts | 6 +- .../ProjectView/AccessSettingsPage.ts | 2 +- tests/playwright/pages/Dashboard/TreeView.ts | 20 +- tests/playwright/pages/OrgAdmin/Bases.ts | 15 ++ tests/playwright/pages/OrgAdmin/Dashboard.ts | 15 ++ tests/playwright/pages/OrgAdmin/Domain.ts | 51 +++++ tests/playwright/pages/OrgAdmin/Members.ts | 15 ++ .../pages/OrgAdmin/OpenIDLoginPage.ts | 46 ++++ .../pages/OrgAdmin/SAMLLoginPage.ts | 42 ++++ tests/playwright/pages/OrgAdmin/SSO.ts | 200 +++++++++++++++++ .../playwright/pages/OrgAdmin/SSOLoginPage.ts | 37 ++++ tests/playwright/pages/OrgAdmin/Settings.ts | 15 ++ tests/playwright/pages/OrgAdmin/Workspaces.ts | 15 ++ tests/playwright/pages/OrgAdmin/index.ts | 29 +++ .../pages/WorkspacePage/CollaborationPage.ts | 25 ++- tests/playwright/setup/index.ts | 7 +- 64 files changed, 1541 insertions(+), 255 deletions(-) create mode 100644 packages/nc-gui/assets/nc-icons/arrow-up-right.svg create mode 100644 packages/nc-gui/assets/nc-icons/control-panel.svg create mode 100644 packages/nc-gui/assets/nc-icons/home.svg create mode 100644 packages/nc-gui/assets/nc-icons/office.svg create mode 100644 packages/nc-gui/assets/nc-icons/slash.svg create mode 100644 packages/nc-gui/assets/nc-icons/workspace.svg create mode 100644 packages/nc-gui/components/dashboard/Sidebar/EEMenuOption.vue rename packages/nc-gui/components/{project/ShareBaseDlg.vue => dlg/InviteDlg.vue} (60%) create mode 100644 packages/nc-gui/components/general/CopyButton.vue create mode 100644 packages/nc-gui/composables/useOrganization.ts create mode 100644 packages/nc-gui/utils/datetimeUtils.ts create mode 100644 tests/playwright/pages/OrgAdmin/Bases.ts create mode 100644 tests/playwright/pages/OrgAdmin/Dashboard.ts create mode 100644 tests/playwright/pages/OrgAdmin/Domain.ts create mode 100644 tests/playwright/pages/OrgAdmin/Members.ts create mode 100644 tests/playwright/pages/OrgAdmin/OpenIDLoginPage.ts create mode 100644 tests/playwright/pages/OrgAdmin/SAMLLoginPage.ts create mode 100644 tests/playwright/pages/OrgAdmin/SSO.ts create mode 100644 tests/playwright/pages/OrgAdmin/SSOLoginPage.ts create mode 100644 tests/playwright/pages/OrgAdmin/Settings.ts create mode 100644 tests/playwright/pages/OrgAdmin/Workspaces.ts create mode 100644 tests/playwright/pages/OrgAdmin/index.ts diff --git a/packages/nc-gui/assets/nc-icons/arrow-up-right.svg b/packages/nc-gui/assets/nc-icons/arrow-up-right.svg new file mode 100644 index 0000000000..b0b9d3026b --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/arrow-up-right.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/nc-gui/assets/nc-icons/control-panel.svg b/packages/nc-gui/assets/nc-icons/control-panel.svg new file mode 100644 index 0000000000..c566e17b96 --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/control-panel.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/nc-gui/assets/nc-icons/home.svg b/packages/nc-gui/assets/nc-icons/home.svg new file mode 100644 index 0000000000..fe8bdeb742 --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/home.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/nc-gui/assets/nc-icons/office.svg b/packages/nc-gui/assets/nc-icons/office.svg new file mode 100644 index 0000000000..b2b313eaf4 --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/office.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packages/nc-gui/assets/nc-icons/slash.svg b/packages/nc-gui/assets/nc-icons/slash.svg new file mode 100644 index 0000000000..8e7e27899e --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/slash.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/packages/nc-gui/assets/nc-icons/workspace.svg b/packages/nc-gui/assets/nc-icons/workspace.svg new file mode 100644 index 0000000000..52c0757116 --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/workspace.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/nc-gui/components.d.ts b/packages/nc-gui/components.d.ts index 0b40fd5fd3..9f38e62348 100644 --- a/packages/nc-gui/components.d.ts +++ b/packages/nc-gui/components.d.ts @@ -52,6 +52,7 @@ declare module 'vue' { ARadio: typeof import('ant-design-vue/es')['Radio'] ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup'] ARate: typeof import('ant-design-vue/es')['Rate'] + AResult: typeof import('ant-design-vue/es')['Result'] ARow: typeof import('ant-design-vue/es')['Row'] ASelect: typeof import('ant-design-vue/es')['Select'] ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] diff --git a/packages/nc-gui/components/dashboard/Sidebar/EEMenuOption.vue b/packages/nc-gui/components/dashboard/Sidebar/EEMenuOption.vue new file mode 100644 index 0000000000..b95f1483e9 --- /dev/null +++ b/packages/nc-gui/components/dashboard/Sidebar/EEMenuOption.vue @@ -0,0 +1,3 @@ + diff --git a/packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue b/packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue index c3efd5f604..f340b5bab6 100644 --- a/packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue +++ b/packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue @@ -20,12 +20,14 @@ const { isMobileMode } = useGlobal() const logout = async () => { isLoggingOut.value = true try { + const isSsoUser = !!(user?.value as any)?.sso_client_id + await signOut(false) // No need as all stores are cleared on signout // await clearWorkspaces() - await navigateTo('/signin') + await navigateTo(isSsoUser ? '/sso' : '/signin') } catch (e) { console.error(e) } finally { @@ -167,6 +169,8 @@ onMounted(() => { + + {{ $t('title.accountSettings') }} diff --git a/packages/nc-gui/components/dashboard/settings/DataSources.vue b/packages/nc-gui/components/dashboard/settings/DataSources.vue index 400d29a878..96ef06ed9a 100644 --- a/packages/nc-gui/components/dashboard/settings/DataSources.vue +++ b/packages/nc-gui/components/dashboard/settings/DataSources.vue @@ -290,11 +290,11 @@ const isEditBaseModalOpen = computed({