fix: [OCISDEV-1435] resolve vault permanent links opened outside the vault (#13001)
This commit is contained in:
1 parent
015c67e9e6
commit
69b4423300
10 files changed
+89
-32
No files matched your search
@@ -0,0 +1,15 @@
|
||||
Bugfix: Open Safe permanent links from outside the Safe
|
||||
|
||||
A permanent link to a file in the Safe, opened in a regular Drive tab, showed
|
||||
"An error occurred while resolving the private link" instead of the file. The
|
||||
Web frontend recognized Safe files by a storage provider id that the server
|
||||
only sends to sessions already inside the Safe, so a Drive tab never redirected
|
||||
the link into the Safe.
|
||||
|
||||
The Safe storage provider id is fixed, so the frontend now uses it as a
|
||||
constant, like the share jail and OCM ids. This also keeps Safe notifications
|
||||
out of the Drive view and lets the invite form recognize Safe resources in
|
||||
Drive mode. The `vaultStorageProvider` getter of the web-pkg capability store
|
||||
is removed; use `VAULT_STORAGE_PROVIDER_ID` from web-client instead.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13001
|
||||
+2
-2
@@ -170,7 +170,7 @@ import {
|
||||
} from '@ownclouders/web-pkg'
|
||||
|
||||
import { computed, inject, ref, unref, watch, onMounted, nextTick, Ref, useTemplateRef } from 'vue'
|
||||
import { Resource, SpaceResource } from '@ownclouders/web-client'
|
||||
import { Resource, SpaceResource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client'
|
||||
import { DateTime } from 'luxon'
|
||||
import { OcDrop } from '@ownclouders/design-system/components'
|
||||
import { useTask } from 'vue-concurrency'
|
||||
@@ -295,7 +295,7 @@ const isVaultResource = computed(() => {
|
||||
if (!unref(capabilityRefs.vaultEnabled) || typeof storageId !== 'string') {
|
||||
return false
|
||||
}
|
||||
return storageId.split('$')[0] === unref(capabilityRefs.vaultStorageProvider)
|
||||
return storageId.split('$')[0] === VAULT_STORAGE_PROVIDER_ID
|
||||
})
|
||||
|
||||
const createSharesConcurrentRequests = computed(() => {
|
||||
|
||||
+8
-7
@@ -7,7 +7,7 @@ import {
|
||||
shallowMount,
|
||||
VueWrapper
|
||||
} from '@ownclouders/web-test-helpers'
|
||||
import { Resource, SpaceResource } from '@ownclouders/web-client'
|
||||
import { Resource, SpaceResource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client'
|
||||
import { useSharesStore } from '@ownclouders/web-pkg'
|
||||
import { CollaboratorAutoCompleteItem, CollaboratorShare, ShareRole } from '@ownclouders/web-client'
|
||||
import { Group, User } from '@ownclouders/web-client/graph/generated'
|
||||
@@ -114,16 +114,17 @@ describe('InviteCollaboratorForm', () => {
|
||||
})
|
||||
})
|
||||
describe('fetching recipients for a vault resource', () => {
|
||||
const vaultStorageProvider = '1a01c2c4-4309-4483-a845-842fd56d8622'
|
||||
// vault resources are recognized by the fixed vault storage provider id, not by the
|
||||
// `vault_storage_provider` capability, which a drive-mode session receives empty
|
||||
const vaultCapabilities = {
|
||||
files_sharing: { federation: { incoming: true, outgoing: true } },
|
||||
vault: { enabled: true, vault_storage_provider: vaultStorageProvider }
|
||||
vault: { enabled: true, vault_storage_provider: '' }
|
||||
}
|
||||
|
||||
it('only asks for users that may access the vault, and for no groups at all', async () => {
|
||||
const { wrapper, mocks } = getWrapper({
|
||||
capabilities: vaultCapabilities,
|
||||
resource: mock<Resource>({ ...folderMock, storageId: vaultStorageProvider })
|
||||
resource: mock<Resource>({ ...folderMock, storageId: VAULT_STORAGE_PROVIDER_ID })
|
||||
})
|
||||
await wrapper.vm.fetchRecipientsTask.last
|
||||
|
||||
@@ -138,7 +139,7 @@ describe('InviteCollaboratorForm', () => {
|
||||
capabilities: vaultCapabilities,
|
||||
resource: mock<SpaceResource>({
|
||||
...spaceMock,
|
||||
storageId: `${vaultStorageProvider}$some-space-id`
|
||||
storageId: `${VAULT_STORAGE_PROVIDER_ID}$some-space-id`
|
||||
})
|
||||
})
|
||||
await wrapper.vm.fetchRecipientsTask.last
|
||||
@@ -165,9 +166,9 @@ describe('InviteCollaboratorForm', () => {
|
||||
const { wrapper, mocks } = getWrapper({
|
||||
capabilities: {
|
||||
...vaultCapabilities,
|
||||
vault: { enabled: false, vault_storage_provider: vaultStorageProvider }
|
||||
vault: { enabled: false }
|
||||
},
|
||||
resource: mock<Resource>({ ...folderMock, storageId: vaultStorageProvider })
|
||||
resource: mock<Resource>({ ...folderMock, storageId: VAULT_STORAGE_PROVIDER_ID })
|
||||
})
|
||||
await wrapper.vm.fetchRecipientsTask.last
|
||||
|
||||
|
||||
@@ -21,3 +21,12 @@ export const PASSWORD_PROTECTED_FOLDER_RENAMED_MESSAGE =
|
||||
* Hiding the extension currently leads to hiding all actions except delete.
|
||||
*/
|
||||
export const HIDDEN_FILE_EXTENSIONS = [PASSWORD_PROTECTED_FOLDER_FILE_EXTENSION]
|
||||
|
||||
/**
|
||||
* Fixed storage provider ids of reva's special storages, mirroring `ShareStorageProviderID`,
|
||||
* `OCMStorageProviderID` and `VaultStorageProviderID` in reva's `pkg/utils`. They are the
|
||||
* same in every deployment.
|
||||
*/
|
||||
export const SHARE_JAIL_ID = 'a0ca6a90-a365-4782-871e-d44447bbc668'
|
||||
export const OCM_PROVIDER_ID = '89f37a33-858b-45fa-8890-a1f2b27d90e1'
|
||||
export const VAULT_STORAGE_PROVIDER_ID = '1a01c2c4-4309-4483-a845-842fd56d8622'
|
||||
@@ -14,9 +14,6 @@ import {
|
||||
} from '@ownclouders/web-client/graph/generated'
|
||||
import { Ability, Resource } from '../resource'
|
||||
|
||||
export const SHARE_JAIL_ID = 'a0ca6a90-a365-4782-871e-d44447bbc668'
|
||||
export const OCM_PROVIDER_ID = '89f37a33-858b-45fa-8890-a1f2b27d90e1'
|
||||
|
||||
export type SpaceMember = {
|
||||
grantedTo: SharePointIdentitySet
|
||||
permissions: string[]
|
||||
|
||||
@@ -163,7 +163,6 @@ export const useCapabilityStore = defineStore('capabilities', () => {
|
||||
const authMfaSessionDuration = computed(() => unref(capabilities).auth.mfa.session_duration)
|
||||
|
||||
const vaultEnabled = computed(() => unref(capabilities).vault?.enabled)
|
||||
const vaultStorageProvider = computed(() => unref(capabilities).vault?.vault_storage_provider)
|
||||
|
||||
return {
|
||||
isInitialized,
|
||||
@@ -216,8 +215,7 @@ export const useCapabilityStore = defineStore('capabilities', () => {
|
||||
authMfaEnabled,
|
||||
authMfaRequiredLevelname,
|
||||
authMfaSessionDuration,
|
||||
vaultEnabled,
|
||||
vaultStorageProvider
|
||||
vaultEnabled
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ import { Notification } from '../../helpers/notifications'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useTask } from 'vue-concurrency'
|
||||
import { MESSAGE_TYPE } from '@ownclouders/web-client/sse'
|
||||
import { call } from '@ownclouders/web-client'
|
||||
import { call, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client'
|
||||
|
||||
const POLLING_INTERVAL = 30000
|
||||
|
||||
@@ -112,7 +112,7 @@ export default {
|
||||
const { isInVault } = useVault()
|
||||
|
||||
const isVaultNotification = (notification: Notification) =>
|
||||
notification.object_id?.split('$')[0] === capabilityStore.vaultStorageProvider
|
||||
notification.object_id?.split('$')[0] === VAULT_STORAGE_PROVIDER_ID
|
||||
|
||||
const notifications = computed(() => {
|
||||
if (!capabilityStore.vaultEnabled) {
|
||||
|
||||
@@ -53,7 +53,12 @@ import { unref, defineComponent, computed, onMounted, ref, Ref } from 'vue'
|
||||
import { dirname } from 'path'
|
||||
import { createFileRouteOptions, useGetResourceContext } from '@ownclouders/web-pkg'
|
||||
import { useTask } from 'vue-concurrency'
|
||||
import { isShareSpaceResource, Resource, SHARE_JAIL_ID } from '@ownclouders/web-client'
|
||||
import {
|
||||
isShareSpaceResource,
|
||||
Resource,
|
||||
SHARE_JAIL_ID,
|
||||
VAULT_STORAGE_PROVIDER_ID
|
||||
} from '@ownclouders/web-client'
|
||||
import { RouteLocationNamedRaw } from 'vue-router'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
|
||||
@@ -92,7 +97,7 @@ export default defineComponent({
|
||||
// fires on a router.push, so it is not the reason for the full reload.
|
||||
if (
|
||||
capabilityStore.vaultEnabled &&
|
||||
id?.split('$')[0] === capabilityStore.vaultStorageProvider &&
|
||||
id?.split('$')[0] === VAULT_STORAGE_PROVIDER_ID &&
|
||||
unref(scope) !== 'vault'
|
||||
) {
|
||||
window.location.replace(
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
mockHttpResponse,
|
||||
shallowMount
|
||||
} from '@ownclouders/web-test-helpers'
|
||||
import { SpaceResource } from '@ownclouders/web-client'
|
||||
import { SpaceResource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client'
|
||||
import { RouterLink, RouteLocationNamedRaw, RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
import Avatar from '../../../../src/components/Avatar.vue'
|
||||
|
||||
@@ -268,7 +268,7 @@ describe('Notification component', () => {
|
||||
messageRich: undefined,
|
||||
computedMessage: undefined,
|
||||
computedLink: undefined,
|
||||
object_id: 'vault-provider$resource-20',
|
||||
object_id: `${VAULT_STORAGE_PROVIDER_ID}$resource-20`,
|
||||
datetime: '2024-01-01T00:00:00Z'
|
||||
})
|
||||
const driveNotification = mock<Notification>({
|
||||
@@ -278,8 +278,13 @@ describe('Notification component', () => {
|
||||
object_id: 'other-provider$resource-22',
|
||||
datetime: '2024-01-01T00:00:01Z'
|
||||
})
|
||||
// a vault session fetches capabilities with `?vault=true` and gets the provider id,
|
||||
// a drive-mode session fetches them without it and gets an empty value
|
||||
const vaultCapabilityState = {
|
||||
capabilities: { vault: { enabled: true, vault_storage_provider: 'vault-provider' } }
|
||||
capabilities: { vault: { enabled: true, vault_storage_provider: VAULT_STORAGE_PROVIDER_ID } }
|
||||
}
|
||||
const driveCapabilityState = {
|
||||
capabilities: { vault: { enabled: true, vault_storage_provider: '' } }
|
||||
}
|
||||
|
||||
it('shows only vault notifications when in vault mode', async () => {
|
||||
@@ -295,7 +300,7 @@ describe('Notification component', () => {
|
||||
vi.mocked(useVault).mockReturnValue({ isInVault: false })
|
||||
const { wrapper } = getWrapper({
|
||||
notifications: [vaultNotification, driveNotification],
|
||||
capabilityState: vaultCapabilityState
|
||||
capabilityState: driveCapabilityState
|
||||
})
|
||||
await wrapper.vm.fetchNotificationsTask.last
|
||||
expect(wrapper.findAll(selectors.notificationItem).length).toBe(1)
|
||||
|
||||
@@ -2,7 +2,12 @@ import resolvePrivateLink from '../../../src/pages/resolvePrivateLink.vue'
|
||||
import { defaultPlugins, defaultComponentMocks, shallowMount } from '@ownclouders/web-test-helpers'
|
||||
import { mock } from 'vitest-mock-extended'
|
||||
import { queryItemAsString, useGetResourceContext, useRouteParam } from '@ownclouders/web-pkg'
|
||||
import { Resource, SHARE_JAIL_ID, SpaceResource } from '@ownclouders/web-client'
|
||||
import {
|
||||
Resource,
|
||||
SHARE_JAIL_ID,
|
||||
SpaceResource,
|
||||
VAULT_STORAGE_PROVIDER_ID
|
||||
} from '@ownclouders/web-client'
|
||||
|
||||
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
|
||||
...(await importOriginal<any>()),
|
||||
@@ -85,9 +90,11 @@ describe('resolvePrivateLink', () => {
|
||||
})
|
||||
})
|
||||
describe('vault permalinks', () => {
|
||||
const vaultCapabilityState = {
|
||||
capabilities: { vault: { enabled: true, vault_storage_provider: 'vault-provider' } }
|
||||
// a drive-mode session fetches capabilities without `?vault=true` and gets no provider id
|
||||
const driveCapabilityState = {
|
||||
capabilities: { vault: { enabled: true, vault_storage_provider: '' } }
|
||||
}
|
||||
const vaultFileId = `${VAULT_STORAGE_PROVIDER_ID}$space!item`
|
||||
|
||||
const originalLocation = window.location
|
||||
afterEach(() => {
|
||||
@@ -104,15 +111,15 @@ describe('resolvePrivateLink', () => {
|
||||
value: { replace, href: '' }
|
||||
})
|
||||
const { wrapper, mocks } = getWrapper({
|
||||
fileId: 'vault-provider$space!item',
|
||||
capabilityState: vaultCapabilityState
|
||||
fileId: vaultFileId,
|
||||
capabilityState: driveCapabilityState
|
||||
})
|
||||
await wrapper.vm.resolvePrivateLinkTask.last
|
||||
expect(replace).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.$router.resolve).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
name: 'resolvePrivateLink',
|
||||
params: { scope: 'vault', fileId: 'vault-provider$space!item' }
|
||||
params: { scope: 'vault', fileId: vaultFileId }
|
||||
})
|
||||
)
|
||||
expect(mocks.$router.push).not.toHaveBeenCalled()
|
||||
@@ -132,7 +139,27 @@ describe('resolvePrivateLink', () => {
|
||||
resource,
|
||||
fileId,
|
||||
path: '/',
|
||||
capabilityState: vaultCapabilityState
|
||||
capabilityState: driveCapabilityState
|
||||
})
|
||||
await wrapper.vm.resolvePrivateLinkTask.last
|
||||
expect(replace).not.toHaveBeenCalled()
|
||||
expect(mocks.$router.push).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not redirect a vault permalink when vault mode is disabled', async () => {
|
||||
const replace = vi.fn()
|
||||
Object.defineProperty(window, 'location', {
|
||||
configurable: true,
|
||||
value: { replace, href: '' }
|
||||
})
|
||||
const space = mock<SpaceResource>({ getDriveAliasAndItem: () => 'personal/home' })
|
||||
const resource = mock<Resource>({ fileId: vaultFileId })
|
||||
const { wrapper, mocks } = getWrapper({
|
||||
space,
|
||||
resource,
|
||||
fileId: vaultFileId,
|
||||
path: '/',
|
||||
capabilityState: { capabilities: { vault: { enabled: false } } }
|
||||
})
|
||||
await wrapper.vm.resolvePrivateLinkTask.last
|
||||
expect(replace).not.toHaveBeenCalled()
|
||||
@@ -145,7 +172,7 @@ describe('resolvePrivateLink', () => {
|
||||
configurable: true,
|
||||
value: { replace, href: '' }
|
||||
})
|
||||
const fileId = 'vault-provider$space!item'
|
||||
const fileId = vaultFileId
|
||||
const space = mock<SpaceResource>({ getDriveAliasAndItem: () => 'personal/home' })
|
||||
const resource = mock<Resource>({ fileId })
|
||||
const { wrapper, mocks } = getWrapper({
|
||||
@@ -154,7 +181,7 @@ describe('resolvePrivateLink', () => {
|
||||
fileId,
|
||||
path: '/',
|
||||
scope: 'vault',
|
||||
capabilityState: vaultCapabilityState
|
||||
capabilityState: driveCapabilityState
|
||||
})
|
||||
await wrapper.vm.resolvePrivateLinkTask.last
|
||||
expect(replace).not.toHaveBeenCalled()
|
||||
|
||||
Reference in new issue
Block a user