public api测试
This commit is contained in:
12
auth.py
12
auth.py
@@ -66,7 +66,17 @@ class APIKeyMiddleware(BaseHTTPMiddleware):
|
||||
"""
|
||||
判断是否跳过鉴权的路径
|
||||
"""
|
||||
# 所有API路径都需要鉴权,不跳过
|
||||
# 公共API路径不需要鉴权
|
||||
public_api_paths = [
|
||||
"/api/contents/public/",
|
||||
]
|
||||
|
||||
# 检查是否是公共API路径
|
||||
for public_path in public_api_paths:
|
||||
if path.startswith(public_path):
|
||||
return True
|
||||
|
||||
# 所有其他API路径都需要鉴权,不跳过
|
||||
# 如果路径以/api开头,则不跳过(需要鉴权)
|
||||
if path.startswith("/api"):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user