fix: allow local development admin password

This commit is contained in:
gti
2026-09-22 16:31:33 -03:00
parent 6bdac245b9
commit 35642959c0
3 changed files with 11 additions and 3 deletions
+2 -2
View File
@@ -37,8 +37,8 @@ def verify_password(password: str, stored: str) -> bool:
def create_admin(session, username: str, password: str):
username = username.strip().lower()
if len(username) < 3 or len(password) < 12:
raise ValueError("username must have 3 characters and password 12 characters")
if len(username) < 3:
raise ValueError("username must have 3 characters")
if session.scalar(select(AdminUser).where(AdminUser.username == username)):
raise ValueError("username already exists")
admin = AdminUser(username=username, password_hash=hash_password(password))
+1 -1
View File
@@ -8,7 +8,7 @@ from central.app.human_auth import create_admin
def main():
username = input("Admin username: ").strip()
password = getpass.getpass("Admin password (12+ chars): ")
password = getpass.getpass("Admin password: ")
confirmation = getpass.getpass("Confirm password: ")
if password != confirmation:
raise SystemExit("passwords do not match")
+8
View File
@@ -44,6 +44,14 @@ def test_password_and_event_redaction_and_retention():
assert session.get(AgentEvent, old.id) is None and session.get(AgentEvent, keep.id) is not None
def test_local_development_admin_accepts_operator_supplied_short_password():
session_factory = setup_db()
with session_factory() as session:
admin = create_admin(session, "admin", "admin")
assert admin.username == "admin"
assert verify_password("admin", admin.password_hash)
def test_health_model_separates_safe_blocked_from_technical_failure():
now = datetime.now(timezone.utc)
recent = SimpleNamespace(last_seen_at=now, failed_products=0, last_job_status="COMPLETED")