v0.1.0: CRM/ERP 系统内测版本 - 安全加固完成
- Docker bridge 网络隔离(8000 端口封死) - Gunicorn 4 Worker 多进程 - Alembic 数据库迁移基线 - 日志轮转 20m×3 - JWT 密钥 + DB 密码 + CORS 收紧 - 3-2-1 备份链路(NAS + R740-B 冷备) - 连接池 pool_pre_ping + pool_recycle=3600
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import psycopg2
|
||||
import bcrypt
|
||||
import json
|
||||
import uuid
|
||||
|
||||
try:
|
||||
conn = psycopg2.connect(
|
||||
host="192.168.1.85",
|
||||
port=5432,
|
||||
user="admin",
|
||||
password="admin_password_2026",
|
||||
dbname="lubrication_crm"
|
||||
)
|
||||
cur = conn.cursor()
|
||||
hash_pw = bcrypt.hashpw(b"admin123", bcrypt.gensalt()).decode("utf-8")
|
||||
permissions_json = json.dumps(["view", "edit"])
|
||||
new_uuid = str(uuid.uuid4())
|
||||
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO users (id, username, password_hash, role, permissions, is_active)
|
||||
VALUES (%s, %s, %s, %s, %s, true)
|
||||
ON CONFLICT (username) DO UPDATE SET password_hash=EXCLUDED.password_hash
|
||||
""",
|
||||
(new_uuid, "admin", hash_pw, "admin", permissions_json)
|
||||
)
|
||||
conn.commit()
|
||||
print("Admin user inserted/updated via SQL script.")
|
||||
except Exception as e:
|
||||
print(f"Database error: {e}")
|
||||
finally:
|
||||
if 'cur' in locals():
|
||||
cur.close()
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user