🔒 Fixed some security issues. Please upgrade!

This commit is contained in:
Mawoka
2024-01-21 19:22:56 +01:00
parent e8e330e385
commit 188a935012
12 changed files with 86 additions and 48 deletions
+1 -2
View File
@@ -14,7 +14,6 @@ from fastapi import APIRouter, Response, HTTPException, Request, Depends, status
from fastapi.background import BackgroundTasks
from fastapi.responses import JSONResponse, RedirectResponse, PlainTextResponse
from fastapi.security import OAuth2PasswordRequestForm
import html
from jose import jwt, JWTError
@@ -78,7 +77,7 @@ async def create_user(user: RouteUser, background_task: BackgroundTasks) -> User
raise HTTPException(status_code=409, detail="User already exists")
user.password = get_password_hash(user.password)
user.username = html.unescape(bleach.clean(user.username, tags=[], strip=True))
user.username = bleach.clean(user.username, tags=[], strip=True)
if len(user.username) == 32:
return JSONResponse({"details": "Username mustn't be 32 characters long"}, 400)
await user.save()