mirror of
https://github.com/alireza0/s-ui.git
synced 2026-08-27 04:17:00 +00:00
v1.5.2
Some checks failed
Release S-UI / build-frontend (push) Has been cancelled
Build S-UI for Windows / build-frontend (push) Has been cancelled
Release S-UI / build-386 (push) Has been cancelled
Release S-UI / build-amd64 (push) Has been cancelled
Release S-UI / build-armv5 (push) Has been cancelled
Release S-UI / build-armv6 (push) Has been cancelled
Release S-UI / build-armv7 (push) Has been cancelled
Release S-UI / build-arm64 (push) Has been cancelled
Release S-UI / build-s390x (push) Has been cancelled
Build S-UI for Windows / build-windows-amd64 (push) Has been cancelled
Build S-UI for Windows / build-windows-arm64 (push) Has been cancelled
Some checks failed
Release S-UI / build-frontend (push) Has been cancelled
Build S-UI for Windows / build-frontend (push) Has been cancelled
Release S-UI / build-386 (push) Has been cancelled
Release S-UI / build-amd64 (push) Has been cancelled
Release S-UI / build-armv5 (push) Has been cancelled
Release S-UI / build-armv6 (push) Has been cancelled
Release S-UI / build-armv7 (push) Has been cancelled
Release S-UI / build-arm64 (push) Has been cancelled
Release S-UI / build-s390x (push) Has been cancelled
Build S-UI for Windows / build-windows-amd64 (push) Has been cancelled
Build S-UI for Windows / build-windows-arm64 (push) Has been cancelled
This commit is contained in:
parent
b9ff0d9626
commit
6cdc7b25a2
4 changed files with 43 additions and 2 deletions
33
cmd/migration/1_5_2.go
Normal file
33
cmd/migration/1_5_2.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package migration
|
||||
|
||||
import (
|
||||
"github.com/alireza0/s-ui/util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// to1_5_2 hashes any plaintext admin passwords stored in the users table so a
|
||||
// leaked database no longer exposes credentials in the clear.
|
||||
func to1_5_2(tx *gorm.DB) error {
|
||||
type userRow struct {
|
||||
Id uint
|
||||
Password string
|
||||
}
|
||||
var users []userRow
|
||||
if err := tx.Raw("SELECT id, password FROM users").Scan(&users).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, u := range users {
|
||||
if u.Password == "" || util.IsHashedPassword(u.Password) {
|
||||
continue
|
||||
}
|
||||
hashed, err := util.HashPassword(u.Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Exec("UPDATE users SET password = ? WHERE id = ?", hashed, u.Id).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -83,6 +83,14 @@ func MigrateDb() {
|
|||
}
|
||||
}
|
||||
|
||||
if dbVersion < "1.5.2" {
|
||||
err = to1_5_2(tx)
|
||||
if err != nil {
|
||||
log.Fatal("Migration to 1.5.2 failed: ", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Set version
|
||||
err = tx.Exec("UPDATE settings SET value = ? WHERE key = ?", currentVersion, "version").Error
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
1.5.1
|
||||
1.5.2
|
||||
2
frontend
2
frontend
|
|
@ -1 +1 @@
|
|||
Subproject commit d99b082e0f9ee82079cea05dcdce5b7d435c8784
|
||||
Subproject commit bc4cda476bfeea2986efef31727afb8c4d4bfb08
|
||||
Loading…
Add table
Add a link
Reference in a new issue