| 12345678910111213141516171819202122232425262728293031 |
- """
- 密码强度检测API路由
- 提供密码强度实时检测的API端点
- """
- from fastapi import APIRouter
- from app.schemas.password_strength_schema import (
- PasswordStrengthRequest,
- PasswordStrengthResponse
- )
- from app.services.password_strength_service import PasswordStrengthService
- router = APIRouter(prefix="/api/password", tags=["密码强度"])
- @router.post(
- "/check-strength",
- response_model=PasswordStrengthResponse,
- summary="检测密码强度",
- description="实时检测密码强度,返回强度等级、分数和改进建议"
- )
- def check_password_strength(request: PasswordStrengthRequest):
- """
- 检测密码强度
-
- 强度等级:
- - weak(弱): 只有小写字母和数字,或单一类型
- - medium(中): 包含小写字母、数字和特殊符号(至少2种)
- - strong(强): 包含大小写字母、数字和特殊符号(至少3种,且包含大小写)
- """
- return PasswordStrengthService.check_password_strength(request.password)
|