mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 11:06:46 +08:00
Merge branch 'feat/r2' into deploy/rag-dev
This commit is contained in:
commit
cb2ca0b533
@ -202,12 +202,12 @@ class PluginDatasourceManager(BasePluginClient):
|
|||||||
raise Exception("No response from plugin daemon")
|
raise Exception("No response from plugin daemon")
|
||||||
|
|
||||||
def validate_provider_credentials(
|
def validate_provider_credentials(
|
||||||
self, tenant_id: str, user_id: str, provider: str, credentials: dict[str, Any]
|
self, tenant_id: str, user_id: str, provider: str, plugin_id: str, credentials: dict[str, Any]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
validate the credentials of the provider
|
validate the credentials of the provider
|
||||||
"""
|
"""
|
||||||
datasource_provider_id = GenericProviderID(provider)
|
# datasource_provider_id = GenericProviderID(provider_id)
|
||||||
|
|
||||||
response = self._request_with_plugin_daemon_response_stream(
|
response = self._request_with_plugin_daemon_response_stream(
|
||||||
"POST",
|
"POST",
|
||||||
@ -216,12 +216,12 @@ class PluginDatasourceManager(BasePluginClient):
|
|||||||
data={
|
data={
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"data": {
|
"data": {
|
||||||
"provider": datasource_provider_id.provider_name,
|
"provider": provider,
|
||||||
"credentials": credentials,
|
"credentials": credentials,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
headers={
|
headers={
|
||||||
"X-Plugin-ID": datasource_provider_id.plugin_id,
|
"X-Plugin-ID": plugin_id,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class DatasourceProviderService:
|
|||||||
:param credentials:
|
:param credentials:
|
||||||
"""
|
"""
|
||||||
credential_valid = self.provider_manager.validate_provider_credentials(
|
credential_valid = self.provider_manager.validate_provider_credentials(
|
||||||
tenant_id=tenant_id, user_id=current_user.id, provider=provider, credentials=credentials
|
tenant_id=tenant_id, user_id=current_user.id, provider=provider, plugin_id=plugin_id, credentials=credentials
|
||||||
)
|
)
|
||||||
if credential_valid:
|
if credential_valid:
|
||||||
# Get all provider configurations of the current workspace
|
# Get all provider configurations of the current workspace
|
||||||
@ -119,13 +119,13 @@ class DatasourceProviderService:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return copy_credentials_list
|
return copy_credentials_list
|
||||||
|
|
||||||
def update_datasource_credentials(self, tenant_id: str, auth_id: str, provider: str, plugin_id: str, credentials: dict) -> None:
|
def update_datasource_credentials(self, tenant_id: str, auth_id: str, provider: str, plugin_id: str, credentials: dict) -> None:
|
||||||
"""
|
"""
|
||||||
update datasource credentials.
|
update datasource credentials.
|
||||||
"""
|
"""
|
||||||
credential_valid = self.provider_manager.validate_provider_credentials(
|
credential_valid = self.provider_manager.validate_provider_credentials(
|
||||||
tenant_id=tenant_id, user_id=current_user.id, provider=provider, credentials=credentials
|
tenant_id=tenant_id, user_id=current_user.id, provider=provider,plugin_id=plugin_id, credentials=credentials
|
||||||
)
|
)
|
||||||
if credential_valid:
|
if credential_valid:
|
||||||
# Get all provider configurations of the current workspace
|
# Get all provider configurations of the current workspace
|
||||||
@ -156,7 +156,7 @@ class DatasourceProviderService:
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
else:
|
else:
|
||||||
raise CredentialsValidateFailedError()
|
raise CredentialsValidateFailedError()
|
||||||
|
|
||||||
def remove_datasource_credentials(self, tenant_id: str, auth_id: str, provider: str, plugin_id: str) -> None:
|
def remove_datasource_credentials(self, tenant_id: str, auth_id: str, provider: str, plugin_id: str) -> None:
|
||||||
"""
|
"""
|
||||||
remove datasource credentials.
|
remove datasource credentials.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user