mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 11:56:55 +08:00
feat: mcp auth
This commit is contained in:
parent
23d073f16c
commit
fa1b497e0f
@ -106,7 +106,7 @@ const MCPModal = ({
|
|||||||
const appIconRef = useRef<HTMLDivElement>(null)
|
const appIconRef = useRef<HTMLDivElement>(null)
|
||||||
const isHovering = useHover(appIconRef)
|
const isHovering = useHover(appIconRef)
|
||||||
const [authMethod, setAuthMethod] = useState(MCPAuthMethod.authentication)
|
const [authMethod, setAuthMethod] = useState(MCPAuthMethod.authentication)
|
||||||
const [isDynamicRegistration, setIsDynamicRegistration] = useState(data?.is_dynamic_registration || false)
|
const [isDynamicRegistration, setIsDynamicRegistration] = useState(isCreate ? true : data?.is_dynamic_registration)
|
||||||
const [clientID, setClientID] = useState(data?.authentication?.client_id || '')
|
const [clientID, setClientID] = useState(data?.authentication?.client_id || '')
|
||||||
const [credentials, setCredentials] = useState(data?.authentication?.client_secret || '')
|
const [credentials, setCredentials] = useState(data?.authentication?.client_secret || '')
|
||||||
|
|
||||||
@ -120,6 +120,9 @@ const MCPModal = ({
|
|||||||
setSseReadTimeout(data.sse_read_timeout || 300)
|
setSseReadTimeout(data.sse_read_timeout || 300)
|
||||||
setHeaders(Object.entries(data.masked_headers || {}).map(([key, value]) => ({ id: uuid(), key, value })))
|
setHeaders(Object.entries(data.masked_headers || {}).map(([key, value]) => ({ id: uuid(), key, value })))
|
||||||
setAppIcon(getIcon(data))
|
setAppIcon(getIcon(data))
|
||||||
|
setIsDynamicRegistration(data.is_dynamic_registration)
|
||||||
|
setClientID(data.authentication?.client_id || '')
|
||||||
|
setCredentials(data.authentication?.client_secret || '')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Reset for create mode
|
// Reset for create mode
|
||||||
@ -130,6 +133,9 @@ const MCPModal = ({
|
|||||||
setSseReadTimeout(300)
|
setSseReadTimeout(300)
|
||||||
setHeaders([])
|
setHeaders([])
|
||||||
setAppIcon(DEFAULT_ICON as AppIconSelection)
|
setAppIcon(DEFAULT_ICON as AppIconSelection)
|
||||||
|
setIsDynamicRegistration(true)
|
||||||
|
setClientID('')
|
||||||
|
setCredentials('')
|
||||||
}
|
}
|
||||||
}, [data])
|
}, [data])
|
||||||
|
|
||||||
@ -322,13 +328,13 @@ const MCPModal = ({
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className={cn('mb-1 flex h-6 items-center', isDynamicRegistration && 'opacity-50')}>
|
<div className={cn('mb-1 flex h-6 items-center', isDynamicRegistration && 'opacity-50')}>
|
||||||
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.credentials')}</span>
|
<span className='system-sm-medium text-text-secondary'>{t('tools.mcp.modal.clientSecret')}</span>
|
||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
value={credentials}
|
value={credentials}
|
||||||
onChange={e => setCredentials(e.target.value)}
|
onChange={e => setCredentials(e.target.value)}
|
||||||
onBlur={e => handleBlur(e.target.value.trim())}
|
onBlur={e => handleBlur(e.target.value.trim())}
|
||||||
placeholder={t('tools.mcp.modal.credentialsPlaceholder')}
|
placeholder={t('tools.mcp.modal.clientSecretPlaceholder')}
|
||||||
disabled={isDynamicRegistration}
|
disabled={isDynamicRegistration}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -206,8 +206,8 @@ const translation = {
|
|||||||
authentication: 'Authentication',
|
authentication: 'Authentication',
|
||||||
useDynamicClientRegistration: 'Use Dynamic Client Registration',
|
useDynamicClientRegistration: 'Use Dynamic Client Registration',
|
||||||
clientID: 'Client ID',
|
clientID: 'Client ID',
|
||||||
credentials: 'Credentials',
|
clientSecret: 'Client Secret',
|
||||||
credentialsPlaceholder: 'Client secret',
|
clientSecretPlaceholder: 'Client Secret',
|
||||||
configurations: 'Configurations',
|
configurations: 'Configurations',
|
||||||
},
|
},
|
||||||
delete: 'Remove MCP Server',
|
delete: 'Remove MCP Server',
|
||||||
|
|||||||
@ -206,8 +206,8 @@ const translation = {
|
|||||||
authentication: '认证',
|
authentication: '认证',
|
||||||
useDynamicClientRegistration: '使用动态客户端注册',
|
useDynamicClientRegistration: '使用动态客户端注册',
|
||||||
clientID: '客户端 ID',
|
clientID: '客户端 ID',
|
||||||
credentials: '凭证',
|
clientSecret: '客户端密钥',
|
||||||
credentialsPlaceholder: '客户端密钥',
|
clientSecretPlaceholder: '客户端密钥',
|
||||||
configurations: '配置',
|
configurations: '配置',
|
||||||
},
|
},
|
||||||
delete: '删除 MCP 服务',
|
delete: '删除 MCP 服务',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user