fix: patch storage quota bypass and harden auth security
All checks were successful
Test / test (push) Successful in 2m11s
All checks were successful
Test / test (push) Successful in 2m11s
- Fix WebDAV chunked PUT bypassing storage quota when remaining_quota <= 0 - Add QuotaLimitedWriter to enforce quota during streaming writes - Clean up residual files on write failure in end_write() - Add Magic Link replay attack prevention via TokenStore - Reject startup when JWT SECRET_KEY is not configured - Sanitize OAuth callback and Magic Link log output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from fastapi import APIRouter, Query
|
||||
from fastapi.responses import PlainTextResponse
|
||||
from loguru import logger as l
|
||||
|
||||
from sqlmodels import ResponseBase
|
||||
import service.oauth
|
||||
@@ -64,16 +65,17 @@ async def router_callback_github(
|
||||
"""
|
||||
try:
|
||||
access_token = await service.oauth.github.get_access_token(code)
|
||||
# [TODO] 把access_token写数据库里
|
||||
if not access_token:
|
||||
return PlainTextResponse("Failed to retrieve access token from GitHub.", status_code=400)
|
||||
|
||||
return PlainTextResponse("GitHub 认证失败", status_code=400)
|
||||
|
||||
user_data = await service.oauth.github.get_user_info(access_token.access_token)
|
||||
# [TODO] 把user_data写数据库里
|
||||
|
||||
return PlainTextResponse(f"User information processed successfully, code: {code}, user_data: {user_data.json_dump()}", status_code=200)
|
||||
# [TODO] 把 access_token 和 user_data 写数据库,生成 JWT,重定向到前端
|
||||
l.info(f"GitHub OAuth 回调成功: user={user_data.user_data.login}")
|
||||
|
||||
return PlainTextResponse("认证成功,功能开发中", status_code=200)
|
||||
except Exception as e:
|
||||
return PlainTextResponse(f"An error occurred: {str(e)}", status_code=500)
|
||||
l.error(f"GitHub OAuth 回调异常: {e}")
|
||||
return PlainTextResponse("认证过程中发生错误,请重试", status_code=500)
|
||||
|
||||
@pay_router.post(
|
||||
path='/alipay',
|
||||
|
||||
@@ -318,7 +318,7 @@ async def router_user_magic_link(
|
||||
site_url = site_url_setting.value if site_url_setting else "http://localhost"
|
||||
|
||||
# TODO: 发送邮件(包含 {site_url}/auth/magic-link?token={token})
|
||||
logger.info(f"Magic Link token 已生成: {token} (邮件发送待实现)")
|
||||
logger.info(f"Magic Link token 已为 {request.email} 生成 (邮件发送待实现)")
|
||||
|
||||
|
||||
@user_router.post(
|
||||
|
||||
Reference in New Issue
Block a user