fix(api): add missing INNER_API_KEY to InnerAPIConfig (#19166)

This commit is contained in:
Yeuoly 2025-05-06 10:02:14 +08:00 committed by GitHub
parent 5a6f20d575
commit 8ac3a223a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -398,6 +398,11 @@ class InnerAPIConfig(BaseSettings):
default=False,
)
INNER_API_KEY: Optional[str] = Field(
description="API key for accessing the internal API",
default=None,
)
class LoggingConfig(BaseSettings):
"""

View File

@ -18,7 +18,7 @@ def enterprise_inner_api_only(view):
# get header 'X-Inner-Api-Key'
inner_api_key = request.headers.get("X-Inner-Api-Key")
if not inner_api_key or inner_api_key != dify_config.INNER_API_KEY_FOR_PLUGIN:
if not inner_api_key or inner_api_key != dify_config.INNER_API_KEY:
abort(401)
return view(*args, **kwargs)

View File

@ -100,3 +100,9 @@ def test_flask_configs(example_env_file):
assert str(config["CODE_EXECUTION_ENDPOINT"]) == "http://sandbox:8194/"
assert str(URL(str(config["CODE_EXECUTION_ENDPOINT"])) / "v1") == "http://sandbox:8194/v1"
def test_inner_api_config_exist():
config = DifyConfig()
assert config.INNER_API is False
assert config.INNER_API_KEY is None