feat: mask hidden values in tenant OAuth client retrieval

feat/rag-2
Harry 10 months ago
parent 529eca70bc
commit 51d7a9b6be

@ -111,7 +111,7 @@ class DatasourceProviderService:
) )
def get_tenant_oauth_client( def get_tenant_oauth_client(
self, tenant_id: str, datasource_provider_id: DatasourceProviderID self, tenant_id: str, datasource_provider_id: DatasourceProviderID, mask: bool = False
) -> dict[str, Any] | None: ) -> dict[str, Any] | None:
""" """
get tenant oauth client get tenant oauth client
@ -128,6 +128,9 @@ class DatasourceProviderService:
) )
if tenant_oauth_client_params: if tenant_oauth_client_params:
encrypter, _ = self.get_oauth_encrypter(tenant_id, datasource_provider_id) encrypter, _ = self.get_oauth_encrypter(tenant_id, datasource_provider_id)
if mask:
return encrypter.mask_tool_credentials(encrypter.decrypt(tenant_oauth_client_params.client_params))
else:
return encrypter.decrypt(tenant_oauth_client_params.client_params) return encrypter.decrypt(tenant_oauth_client_params.client_params)
return None return None
@ -416,8 +419,7 @@ class DatasourceProviderService:
"author": datasource.declaration.identity.author, "author": datasource.declaration.identity.author,
"credentials_list": credentials, "credentials_list": credentials,
"credential_schema": [ "credential_schema": [
credential.model_dump() credential.model_dump() for credential in datasource.declaration.credentials_schema
for credential in datasource.declaration.credentials_schema
], ],
"oauth_schema": { "oauth_schema": {
"client_schema": [ "client_schema": [
@ -428,7 +430,9 @@ class DatasourceProviderService:
credential_schema.model_dump() credential_schema.model_dump()
for credential_schema in datasource.declaration.oauth_schema.credentials_schema for credential_schema in datasource.declaration.oauth_schema.credentials_schema
], ],
"oauth_custom_client_params": self.get_tenant_oauth_client(tenant_id, datasource_provider_id), "oauth_custom_client_params": self.get_tenant_oauth_client(
tenant_id, datasource_provider_id, mask=True
),
"is_oauth_custom_client_enabled": self.is_tenant_oauth_params_enabled( "is_oauth_custom_client_enabled": self.is_tenant_oauth_params_enabled(
tenant_id, datasource_provider_id tenant_id, datasource_provider_id
), ),

Loading…
Cancel
Save