mirror of
https://github.com/langgenius/dify.git
synced 2026-08-01 18:30:48 +08:00
fix(web): skip auth validation for local file datasource (#39856)
This commit is contained in:
parent
37bf80dcf6
commit
b4d93b02fd
@ -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',
|
||||
)
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user