truncate passwords to 72 bytes to prevent bcrypt hashing errors
This commit is contained in:
parent
bb7053b01e
commit
7dcda4b5ef
2 changed files with 5 additions and 3 deletions
5
main.py
5
main.py
|
|
@ -37,10 +37,11 @@ app = FastAPI()
|
||||||
app.add_middleware(SessionMiddleware, secret_key=ENCRYPTION_KEY)
|
app.add_middleware(SessionMiddleware, secret_key=ENCRYPTION_KEY)
|
||||||
|
|
||||||
def get_password_hash(password):
|
def get_password_hash(password):
|
||||||
return pwd_context.hash(password)
|
# bcrypt has a 72-byte limit
|
||||||
|
return pwd_context.hash(password[:72])
|
||||||
|
|
||||||
def verify_password(plain_password, hashed_password):
|
def verify_password(plain_password, hashed_password):
|
||||||
return pwd_context.verify(plain_password, hashed_password)
|
return pwd_context.verify(plain_password[:72], hashed_password)
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
conn = sqlite3.connect(DB_PATH)
|
conn = sqlite3.connect(DB_PATH)
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@ pyotp==2.9.0
|
||||||
httpx==0.25.1
|
httpx==0.25.1
|
||||||
pydantic==2.4.2
|
pydantic==2.4.2
|
||||||
itsdangerous==2.1.2
|
itsdangerous==2.1.2
|
||||||
passlib[bcrypt]==1.7.4
|
passlib==1.7.4
|
||||||
|
bcrypt==3.2.2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue