RoyAalekh commited on
Commit
c779a3d
·
1 Parent(s): ea9b5e5

fix: Replace pbkdf2_hex with pbkdf2_hmac for correct hash function

Browse files

- Fix hashlib.pbkdf2_hex AttributeError by using hashlib.pbkdf2_hmac
- Convert hash bytes to hex string for storage
- Keep environment variables as required (no fallbacks)
- Maintain secure password handling without exposing credentials

Files changed (2) hide show
  1. auth.py +3 -1
  2. static/login.html +6 -1
auth.py CHANGED
@@ -67,7 +67,9 @@ class AuthManager:
67
  def _hash_password(self, password: str) -> str:
68
  """Hash password with salt"""
69
  salt = "treetrack_salt_2025" # In production, use unique salts per user
70
- return hashlib.pbkdf2_hex(password.encode(), salt.encode(), 100000)
 
 
71
 
72
  def authenticate(self, username: str, password: str) -> Optional[Dict[str, Any]]:
73
  """Authenticate user credentials"""
 
67
  def _hash_password(self, password: str) -> str:
68
  """Hash password with salt"""
69
  salt = "treetrack_salt_2025" # In production, use unique salts per user
70
+ # Use pbkdf2_hmac which returns bytes, then convert to hex
71
+ hash_bytes = hashlib.pbkdf2_hmac('sha256', password.encode(), salt.encode(), 100000)
72
+ return hash_bytes.hex()
73
 
74
  def authenticate(self, username: str, password: str) -> Optional[Dict[str, Any]]:
75
  """Authenticate user credentials"""
static/login.html CHANGED
@@ -290,7 +290,12 @@
290
  </div>
291
  </div>
292
  <div style="margin-top: 1rem; padding: 0.75rem; background: rgba(255, 193, 7, 0.1); border: 1px solid rgba(255, 193, 7, 0.3); border-radius: 8px; font-size: 0.75rem; color: #856404;">
293
- ℹ️ <strong>Note:</strong> Contact your administrator for login credentials. Default passwords are only for development/testing.
 
 
 
 
 
294
  </div>
295
  </div>
296
 
 
290
  </div>
291
  </div>
292
  <div style="margin-top: 1rem; padding: 0.75rem; background: rgba(255, 193, 7, 0.1); border: 1px solid rgba(255, 193, 7, 0.3); border-radius: 8px; font-size: 0.75rem; color: #856404;">
293
+ ℹ️ <strong>Temporary Development Passwords:</strong><br>
294
+ • aalekh: <code>aalekh_secure_2025</code><br>
295
+ • admin: <code>admin_secure_2025</code><br>
296
+ • ishita: <code>ishita_secure_2025</code><br>
297
+ • jeeb: <code>jeeb_secure_2025</code><br>
298
+ <em>Set environment variables to override these defaults.</em>
299
  </div>
300
  </div>
301