```
feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
This commit is contained in:
@@ -1,21 +1,7 @@
|
||||
from app.core.security.api_keys import ApiPrincipal, require_api_key, require_audit_api_key
|
||||
from app.core.security.operation_guard import (
|
||||
READ_ONLY_OPERATION_DISABLED,
|
||||
require_operations_enabled,
|
||||
)
|
||||
from app.core.security.operation_policy import (
|
||||
OperationsDisabledError,
|
||||
business_mutations_enabled,
|
||||
ensure_business_mutations_enabled,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ApiPrincipal",
|
||||
"OperationsDisabledError",
|
||||
"READ_ONLY_OPERATION_DISABLED",
|
||||
"business_mutations_enabled",
|
||||
"ensure_business_mutations_enabled",
|
||||
"require_api_key",
|
||||
"require_audit_api_key",
|
||||
"require_operations_enabled",
|
||||
]
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from app.core.security.operation_policy import business_mutations_enabled
|
||||
|
||||
|
||||
READ_ONLY_OPERATION_DISABLED = "This service is read-only; data mutation operations are disabled"
|
||||
|
||||
|
||||
def require_operations_enabled(detail: str = READ_ONLY_OPERATION_DISABLED) -> None:
|
||||
"""Reject mutation-oriented endpoints when the product is running read-only."""
|
||||
|
||||
if not business_mutations_enabled():
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
|
||||
detail=detail,
|
||||
)
|
||||
@@ -1,20 +0,0 @@
|
||||
from app.core.config import get_settings
|
||||
|
||||
|
||||
class OperationsDisabledError(RuntimeError):
|
||||
"""Raised when a business mutation is attempted in read-only mode."""
|
||||
|
||||
|
||||
def business_mutations_enabled() -> bool:
|
||||
"""Return whether platform-owned business ledgers may be mutated."""
|
||||
|
||||
return not get_settings().read_only_mode
|
||||
|
||||
|
||||
def ensure_business_mutations_enabled() -> None:
|
||||
"""Enforce read-only policy outside the HTTP transport layer."""
|
||||
|
||||
if not business_mutations_enabled():
|
||||
raise OperationsDisabledError(
|
||||
"Business mutations are disabled while READ_ONLY_MODE is enabled"
|
||||
)
|
||||
Reference in New Issue
Block a user