mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: OAuth 密钥编辑时显示到期时间和重新授权按钮
- 后端 EndpointAPIKeyResponse 新增 oauth_expires_at 字段 - 从加密的 auth_config 中解密并提取 OAuth Token 到期时间 - 前端编辑已授权的 OAuth 密钥时显示"重新授权"按钮 - 在按钮旁显示 Token 到期时间
This commit is contained in:
@@ -628,7 +628,17 @@ def _build_key_response(
|
||||
key_dict = key.__dict__.copy()
|
||||
key_dict.pop("_sa_instance_state", None)
|
||||
key_dict.pop("api_key", None) # 移除敏感字段,避免泄露
|
||||
key_dict.pop("auth_config", None) # 移除敏感字段,避免泄露
|
||||
|
||||
# 提取 OAuth expires_at(如果是 OAuth 类型)
|
||||
oauth_expires_at = None
|
||||
encrypted_auth_config = key_dict.pop("auth_config", None) # 移除敏感字段,避免泄露
|
||||
if auth_type == "oauth" and encrypted_auth_config:
|
||||
try:
|
||||
decrypted_config = crypto_service.decrypt(encrypted_auth_config)
|
||||
auth_config = json.loads(decrypted_config)
|
||||
oauth_expires_at = auth_config.get("expires_at")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 从 health_by_format 计算汇总字段(便于列表展示)
|
||||
health_by_format = key.health_by_format or {}
|
||||
@@ -673,6 +683,8 @@ def _build_key_response(
|
||||
"consecutive_failures": max_consecutive,
|
||||
"last_failure_at": last_failure,
|
||||
"circuit_breaker_open": any_circuit_open,
|
||||
# OAuth 相关
|
||||
"oauth_expires_at": oauth_expires_at,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user