Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): skip auth validation for local file datasource (#39856)

非法操作b4d93b02fd55
diff --git a/web/app/components/workflow/utils/__tests__/data-source.spec.ts b/web/app/components/workflow/utils/__tests__/data-source.spec.ts
index 300ad3196af..f909f5db6a1 100644
--- a/web/app/components/workflow/utils/__tests__/data-source.spec.ts
+++ b/web/app/components/workflow/utils/__tests__/data-source.spec.ts
@@ -69,19 +69,29 @@ describe('getDataSourceCheckParams', () => {
])
})
- it('should mark an unauthorized datasource as not authed', () => {
+ it('should not require authorization for a local file datasource', () => {
const result = getDataSourceCheckParams(
createDataSourceData(),
[createDataSourceCollection()],
'en_US',
)
+ expect(result.notAuthed).toBe(false)
+ })
+
+ it('should mark an unauthorized online datasource as not authed', () => {
+ const result = getDataSourceCheckParams(
+ createDataSourceData({ provider_type: 'online_document' }),
+ [createDataSourceCollection()],
+ 'en_US',
+ )
+
expect(result.notAuthed).toBe(true)
})
it('should mark as authed when is_authorized is true', () => {
const result = getDataSourceCheckParams(
- createDataSourceData(),
+ createDataSourceData({ provider_type: 'online_document' }),
[createDataSourceCollection({ is_authorized: true })],
'en_US',
)
diff --git a/web/app/components/workflow/utils/data-source.ts b/web/app/components/workflow/utils/data-source.ts
index 3151dd784fa..dd6171abc4d 100644
--- a/web/app/components/workflow/utils/data-source.ts
+++ b/web/app/components/workflow/utils/data-source.ts
@@ -1,13 +1,14 @@
import type { DataSourceNodeType } from '../nodes/data-source/types'
import type { InputVar, ToolWithProvider } from '../types'
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
+import { DataSourceClassification } from '../nodes/data-source/types'
export const getDataSourceCheckParams = (
toolData: DataSourceNodeType,
dataSourceList: ToolWithProvider[],
language: string,
) => {
- const { plugin_id, datasource_name } = toolData
+ const { plugin_id, provider_type, datasource_name } = toolData
const currentDataSource = dataSourceList.find((item) => item.plugin_id === plugin_id)
const currentDataSourceItem = currentDataSource?.tools.find(
(tool) => tool.name === datasource_name,
@@ -30,7 +31,10 @@ export const getDataSourceCheckParams = (
})
return formInputs
})(),
- notAuthed: !!currentDataSource?.allow_delete && !currentDataSource?.is_authorized,
+ notAuthed:
+ provider_type !== DataSourceClassification.localFile &&
+ !!currentDataSource?.allow_delete &&
+ !currentDataSource?.is_authorized,
language,
}
}