mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
feat(oauth): update client parameters handling and improve oauth_params parsing
This commit is contained in:
parent
f68201af0b
commit
37be099442
@ -55,7 +55,7 @@ class ToolOAuthTenantClient(Base):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def oauth_params(self) -> dict:
|
def oauth_params(self) -> dict:
|
||||||
return cast(dict, json.loads(self.encrypted_oauth_params))
|
return cast(dict, json.loads(self.encrypted_oauth_params or "{}"))
|
||||||
|
|
||||||
|
|
||||||
class BuiltinToolProvider(Base):
|
class BuiltinToolProvider(Base):
|
||||||
|
|||||||
@ -53,12 +53,9 @@ class BuiltinToolManageService:
|
|||||||
"schema": provider.get_oauth_client_schema(),
|
"schema": provider.get_oauth_client_schema(),
|
||||||
"is_oauth_custom_client_enabled": is_oauth_custom_client_enabled,
|
"is_oauth_custom_client_enabled": is_oauth_custom_client_enabled,
|
||||||
"is_system_oauth_params_exists": is_system_oauth_params_exists,
|
"is_system_oauth_params_exists": is_system_oauth_params_exists,
|
||||||
|
"client_params": BuiltinToolManageService.get_custom_oauth_client_params(tenant_id, provider_name),
|
||||||
|
"redirect_uri": f"{dify_config.CONSOLE_API_URL}/console/api/oauth/plugin/{provider_name}/tool/callback",
|
||||||
}
|
}
|
||||||
if is_oauth_custom_client_enabled:
|
|
||||||
result["client_params"] = BuiltinToolManageService.get_oauth_client(tenant_id, provider_name)
|
|
||||||
result["redirect_uri"] = (
|
|
||||||
f"{dify_config.CONSOLE_API_URL}/console/api/oauth/plugin/{provider_name}/tool/callback"
|
|
||||||
)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -728,9 +725,4 @@ class BuiltinToolManageService:
|
|||||||
cache=NoOpProviderCredentialCache(),
|
cache=NoOpProviderCredentialCache(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return encrypter.mask_tool_credentials(encrypter.decrypt(custom_oauth_client_params.oauth_params))
|
||||||
"oauth_params": encrypter.mask_tool_credentials(
|
|
||||||
encrypter.decrypt(custom_oauth_client_params.oauth_params)
|
|
||||||
),
|
|
||||||
"enabled": custom_oauth_client_params.enabled,
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user