mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 03:36:36 +08:00
refactor: encryption
This commit is contained in:
parent
1d575524c3
commit
4c28034224
@ -16,7 +16,16 @@ class PluginEncrypter:
|
|||||||
provider_identity=payload.identity,
|
provider_identity=payload.identity,
|
||||||
)
|
)
|
||||||
|
|
||||||
if payload.opt == "encrypt":
|
try:
|
||||||
return encrypter.encrypt(payload.data)
|
if payload.opt == "encrypt":
|
||||||
else:
|
return {
|
||||||
return encrypter.decrypt(payload.data)
|
"data": encrypter.encrypt(payload.data),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
"data": encrypter.decrypt(payload.data),
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
"error": str(e),
|
||||||
|
}
|
||||||
|
|||||||
@ -1,11 +1,28 @@
|
|||||||
|
from collections.abc import Mapping
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from core.entities.provider_entities import ProviderConfig
|
||||||
from core.plugin.entities.base import BasePluginEntity
|
from core.plugin.entities.base import BasePluginEntity
|
||||||
|
|
||||||
|
|
||||||
|
class EndpointDeclaration(BaseModel):
|
||||||
|
"""
|
||||||
|
declaration of an endpoint
|
||||||
|
"""
|
||||||
|
|
||||||
|
settings: Mapping[str, ProviderConfig] = Field(default_factory=Mapping)
|
||||||
|
|
||||||
|
|
||||||
class EndpointEntity(BasePluginEntity):
|
class EndpointEntity(BasePluginEntity):
|
||||||
|
"""
|
||||||
|
entity of an endpoint
|
||||||
|
"""
|
||||||
|
|
||||||
settings: dict
|
settings: dict
|
||||||
hook_id: str
|
hook_id: str
|
||||||
tenant_id: str
|
tenant_id: str
|
||||||
plugin_id: str
|
plugin_id: str
|
||||||
expired_at: datetime
|
expired_at: datetime
|
||||||
|
declaration: EndpointDeclaration = Field(default_factory=EndpointDeclaration)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user