当前位置: 首页 > news >正文

Konga密码重置

1、登录数据库psql

pg-konga-postgresql-0:/$ psql -U konga -d konga
Password for user konga: 
psql (11.20)
Type "help" for help.

konga=> \d+ konga_users;
                                                             Table "public.konga_users"
     Column      |           Type           | Collation | Nullable |                 Default                 | Storage  | Stats target | Description 
-----------------+--------------------------+-----------+----------+-----------------------------------------+----------+--------------+-------------
 id              | integer                  |           | not null | nextval('konga_users_id_seq'::regclass) | plain    |              | 
 username        | text                     |           |          |                                         | extended |              | 
 email           | text                     |           |          |                                         | extended |              | 
 firstName       | text                     |           |          |                                         | extended |              | 
 lastName        | text                     |           |          |                                         | extended |              | 
 admin           | boolean                  |           |          |                                         | plain    |              | 
 node_id         | text                     |           |          |                                         | extended |              | 
 active          | boolean                  |           |          |                                         | plain    |              | 
 activationToken | text                     |           |          |                                         | extended |              | 
 node            | integer                  |           |          |                                         | plain    |              | 
 createdAt       | timestamp with time zone |           |          |                                         | plain    |              | 
 updatedAt       | timestamp with time zone |           |          |                                         | plain    |              | 
 createdUserId   | integer                  |           |          |                                         | plain    |              | 
 updatedUserId   | integer                  |           |          |                                         | plain    |              | 
Indexes:
    "konga_users_pkey" PRIMARY KEY, btree (id)
    "konga_users_email_key" UNIQUE CONSTRAINT, btree (email)
    "konga_users_username_key" UNIQUE CONSTRAINT, btree (username)

发现konga_users没有password字段
发现原来是password存在另一个表中

konga=> \d konga_passports
                                       Table "public.konga_passports"
   Column   |           Type           | Collation | Nullable |                   Default                   
------------+--------------------------+-----------+----------+---------------------------------------------
 id         | integer                  |           | not null | nextval('konga_passports_id_seq'::regclass)
 protocol   | text                     |           |          | 
 password   | text                     |           |          | 
 provider   | text                     |           |          | 
 identifier | text                     |           |          | 
 tokens     | json                     |           |          | 
 user       | integer                  |           |          | 
 createdAt  | timestamp with time zone |           |          | 
 updatedAt  | timestamp with time zone |           |          | 
Indexes:
    "konga_passports_pkey" PRIMARY KEY, btree (id)

2、编写加密脚本

import bcrypt
import sys

# 从命令行获取新密码,或者直接在这里设置
if len(sys.argv) > 1:
    new_password = sys.argv[1]
else:
    new_password = "sdfewfafa" # 在这里输入你的新密码

# 确保密码是字节串
password_bytes = new_password.encode('utf-8')

# 生成哈希 (rounds=10 是 bcrypt 的一个常见参数)
# Konga 0.14.9 可能使用默认 rounds,10 是个安全的猜测
hashed_password = bcrypt.hashpw(password_bytes, bcrypt.gensalt(rounds=10))

# 打印出可用于 SQL 更新的哈希字符串
print(hashed_password.decode('utf-8'))
python bcrypt_pass.py 
$2b$10$s8MGdm7K4jDw8V7GDMNCLujZP1PehXVN2GoiPQedAu2Waib.fw7Pq

3、修改数据表密码

UPDATE konga_passports
SET password = '$2b$10$s8MGdm7K4jDw8V7GDMNCLujZP1PehXVN2GoiPQedAu2Waib.fw7Pq'
WHERE "user" = 1 AND provider = 'local';

其中user的id值是在konga_users中要改的账号的id

konga控制台也可以更改,但是目前没有生效

NODE_ENV=development node /app/bin/konga.js prepare --uri postgres://konga:sfdfef@pg-konga-postgresql.host:5432/konga --admin-user admin --admin-pass asdfefs

相关文章:

  • Node.js项目开启多进程的2种方案
  • C/C++的数据类型
  • 编程通用-配置文件的选择
  • Django从零搭建卖家中心登陆与注册实战
  • 为了四季度的盈利,李斌的换人还在继续
  • Java Stream深度解析 高阶技巧与性能优化实战
  • 高等数学同步测试卷 同济7版 试卷部分 上 做题记录 第三章微分中值定理与导数的应用同步测试卷 B 卷
  • C++中string库常用函数超详细解析与深度实践
  • Java数组初始化全解析:方式、场景与最佳实践
  • 嵌入式基础(二)ARM基础
  • 瑞幸微RK系列平台的YOLO部署(上篇)
  • Python学习笔记(列表)
  • 使用wpa_cli和wpa_supplicant配置Liunx开发板的wlan0无线网
  • idea的快捷键使用以及相关设置
  • mybatis--多对一处理/一对多处理
  • 数据库的种类及常见类型
  • L3-027 可怜的复杂度(纯暴力)
  • 供应链管理:供应链管理的边界
  • HTTP协议 --- 超文本传输协议 和 TCP --- 传输控制协议
  • 什么是端点日志监控
  • 人民日报首推“大地书单”,10本好书上榜!
  • 亮相!神二十乘组与中外媒体记者集体见面
  • 贵州省交通运输厅原副厅长冯伟已任遵义市领导
  • 浦江观察|3.6亿元消费券,为上海餐饮业带来了什么?
  • 降低血压可减少痴呆症发生风险
  • 著名水声学家陆佶人逝世,曾参加我国第一代核潜艇主动声纳研制