From 153abb181d2ed9175f0339f6d340dab89531503b Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Tue, 20 May 2025 14:53:23 +0800 Subject: [PATCH] feat: add PluginVerification --- api/core/plugin/entities/plugin_daemon.py | 14 ++++++++++++++ api/services/feature_service.py | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/api/core/plugin/entities/plugin_daemon.py b/api/core/plugin/entities/plugin_daemon.py index 2bea07bea0..b03e5ed1a6 100644 --- a/api/core/plugin/entities/plugin_daemon.py +++ b/api/core/plugin/entities/plugin_daemon.py @@ -156,9 +156,23 @@ class PluginInstallTaskStartResponse(BaseModel): task_id: str = Field(description="The ID of the install task.") +class PluginVerification(BaseModel): + """ + Verification of the plugin. + """ + + class AuthorizedCategory(StrEnum): + Langgenius = "langgenius" + Partner = "partner" + Community = "community" + + authorized_category: AuthorizedCategory = Field(description="The authorized category of the plugin.") + + class PluginUploadResponse(BaseModel): unique_identifier: str = Field(description="The unique identifier of the plugin.") manifest: PluginDeclaration + verification: Optional[PluginVerification] = Field(default=None, description="Basic verification information") class PluginOAuthAuthorizationUrlResponse(BaseModel): diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 8fd61c221a..312e3acc3f 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -88,13 +88,20 @@ class WebAppAuthModel(BaseModel): allow_email_password_login: bool = False +class PluginInstallationScope(StrEnum): + NONE = "none" + OFFICIAL_ONLY = "official_only" + OFFICIAL_AND_SPECIFIC_PARTNERS = "official_and_specific_partners" + ALL = "all" + + class PluginInstallationPermissionModel(BaseModel): # Plugin installation scope – possible values: # none: prohibit all plugin installations # official_only: allow only Dify official plugins # official_and_specific_partners: allow official and specific partner plugins # all: allow installation of all plugins - plugin_installation_scope: str = "all" + plugin_installation_scope: PluginInstallationScope = PluginInstallationScope.ALL # If True, restrict plugin installation to the marketplace only restrict_to_marketplace_only: bool = False