suhail commited on
Commit
4b49493
·
1 Parent(s): cac2b72
Files changed (3) hide show
  1. Dockerfile +3 -0
  2. requirements.txt +3 -2
  3. src/core/security.py +4 -4
Dockerfile CHANGED
@@ -91,6 +91,9 @@ RUN apt-get update && apt-get install -y \
91
  postgresql-client \
92
  && rm -rf /var/lib/apt/lists/*
93
 
 
 
 
94
  # Copy and install Python dependencies
95
  COPY requirements.txt .
96
  RUN pip install --upgrade pip
 
91
  postgresql-client \
92
  && rm -rf /var/lib/apt/lists/*
93
 
94
+ RUN pip uninstall -y bcrypt && \
95
+ pip install bcrypt==4.0.1 passlib[bcrypt]==1.7.4
96
+
97
  # Copy and install Python dependencies
98
  COPY requirements.txt .
99
  RUN pip install --upgrade pip
requirements.txt CHANGED
@@ -14,9 +14,10 @@ pytest
14
 
15
  httpx
16
  PyJWT
17
- passlib
 
18
  python-multipart
19
- bcrypt
20
  # AI Chatbot dependencies
21
  google-generativeai
22
  tiktoken
 
14
 
15
  httpx
16
  PyJWT
17
+ passlib[bcrypt]==1.7.4
18
+
19
  python-multipart
20
+ bcrypt==4.0.1
21
  # AI Chatbot dependencies
22
  google-generativeai
23
  tiktoken
src/core/security.py CHANGED
@@ -140,10 +140,10 @@ def _bcrypt_safe(password: str) -> bytes:
140
 
141
 
142
  def hash_password(password: str) -> str:
143
- """
144
- Hash password safely (NO crashes).
145
- """
146
- return pwd_context.hash(_bcrypt_safe(password))
147
 
148
 
149
  def verify_password(plain_password: str, hashed_password: str) -> bool:
 
140
 
141
 
142
  def hash_password(password: str) -> str:
143
+ if len(password.encode("utf-8")) > 72:
144
+ raise ValueError("Password too long (max 72 bytes)")
145
+ return pwd_context.hash(password)
146
+
147
 
148
 
149
  def verify_password(plain_password: str, hashed_password: str) -> bool: