演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
783 B
Python
25 lines
783 B
Python
"""Single-source visibility filter for the /openapi/v1/* surface.
|
|
|
|
Keep every openapi-surface app query routed through ``_apply_openapi_gate``;
|
|
retiring or replacing the gate then becomes a one-line change here.
|
|
|
|
The Service API (/v1/* app-key surface) does NOT use this helper — that
|
|
surface has its own per-request guard (``service_api_disabled``) wired
|
|
into the legacy ``validate_app_token`` decorator.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from models.model import App
|
|
|
|
|
|
def apply_openapi_gate(query: Any) -> Any:
|
|
"""Filter a SQLAlchemy Select/Query to apps visible on /openapi/v1/*.
|
|
|
|
Works with both legacy ``Query.filter`` and 2.0-style ``Select.filter``
|
|
(alias of ``.where``).
|
|
"""
|
|
return query.filter(App.enable_api.is_(True))
|