[PR #2966] [MERGED] feat(db)!: hash passwords with bcrypt in database #5312

Closed
opened 2026-10-31 20:46:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/2966
Author: @Columbiysky
Created: 5/2/2025
Status: ✅ Merged
Merged: 5/3/2025
Merged by: @sh1shd

Base: main ← Head: hash-user-passwords


📝 Commits (4)

  • 84dbcf7 feat(db)!: crypting user password as SHA256
  • 049e0c4 feat(db): migration, and seeder hash existing passwords
  • 579c73d refactor(db): a bit better code
  • daec80f refactor(crypto,db): using bcrypt and bcrypt.CompareHashAndPassword instead of SHA256

📊 Changes

5 files changed (+101 additions, -10 deletions)

View changed files

📝 database/db.go (+54 -3)
📝 database/model/model.go (+5 -0)
➕ util/crypto/crypto.go (+15 -0)
📝 web/controller/setting.go (+3 -2)
📝 web/service/user.go (+24 -5)

📄 Description

What is the pull request?

Storing users passwords as a plain text isn't good idea generally. This PR contains changes to hash passwords with SHA256 in DB.
This PR is just an idea, if maintainers will accept it, I'll write better code for this.
I've tested:

  • First time start panel, when .db doesn't exist
  • Changing password for admin account
  • Updating .db to hash password (using runSeeders() function in db.go for this)
  • Of course, logging in panel after hashing password and changing in panel settings

Which part of the application is affected by the change?

  • Frontend
  • Backend

Type of Changes

  • Bug fix
  • New feature
  • Refactoring
  • Other

Screenshots


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/2966 **Author:** [@Columbiysky](https://github.com/Columbiysky) **Created:** 5/2/2025 **Status:** ✅ Merged **Merged:** 5/3/2025 **Merged by:** [@sh1shd](https://github.com/sh1shd) **Base:** `main` ← **Head:** `hash-user-passwords` --- ### 📝 Commits (4) - [`84dbcf7`](https://github.com/MHSanaei/3x-ui/commit/84dbcf7869ccd93f092cae8c0f21df9477e28ff6) feat(db)!: crypting user password as SHA256 - [`049e0c4`](https://github.com/MHSanaei/3x-ui/commit/049e0c405626dddfa35843ec682d482e14852272) feat(db): migration, and seeder hash existing passwords - [`579c73d`](https://github.com/MHSanaei/3x-ui/commit/579c73df4918dd038f7f33770123aa340ec22df4) refactor(db): a bit better code - [`daec80f`](https://github.com/MHSanaei/3x-ui/commit/daec80fc5dcaea899fad6074a0040aad612da79e) refactor(crypto,db): using bcrypt and bcrypt.CompareHashAndPassword instead of SHA256 ### 📊 Changes **5 files changed** (+101 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `database/db.go` (+54 -3) 📝 `database/model/model.go` (+5 -0) ➕ `util/crypto/crypto.go` (+15 -0) 📝 `web/controller/setting.go` (+3 -2) 📝 `web/service/user.go` (+24 -5) </details> ### 📄 Description ## What is the pull request? Storing users passwords as a plain text isn't good idea generally. This PR contains changes to hash passwords with SHA256 in DB. This PR is just an idea, if maintainers will accept it, I'll write better code for this. I've tested: - First time start panel, when .db doesn't exist - Changing password for admin account - Updating .db to hash password (using runSeeders() function in db.go for this) - Of course, logging in panel after hashing password and changing in panel settings ## Which part of the application is affected by the change? - [ ] Frontend - [x] Backend ## Type of Changes - [ ] Bug fix - [x] New feature - [x] Refactoring - [ ] Other ## Screenshots <!-- Add screenshots to illustrate the changes --> <!-- Remove this section if it is not applicable. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:46:06 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5312
No description provided.