mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 03:10:46 +08:00
Gate netx Web/API/WebCRT with JWT and per-user API tokens, bootstrap an admin with forced password change, and expose users/audit/API-key management under a System section. MCP can reuse data/auth/mcp_token without extra env for local labs. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
507 B
Python
20 lines
507 B
Python
"""Password hashing helpers (bcrypt)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import bcrypt
|
|
|
|
|
|
def hash_password(password: str) -> str:
|
|
raw = str(password or "").encode("utf-8")
|
|
return bcrypt.hashpw(raw, bcrypt.gensalt()).decode("ascii")
|
|
|
|
|
|
def verify_password(password: str, password_hash: str) -> bool:
|
|
try:
|
|
return bcrypt.checkpw(
|
|
str(password or "").encode("utf-8"),
|
|
str(password_hash or "").encode("ascii"),
|
|
)
|
|
except Exception:
|
|
return False
|