This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop bcrypt in favor of salted SHA512
With bcrypt, due to its own per-generation salt, we could not select from MySQL for mlchkid, i.e for check.cgi, as we don't know the mlid.
- Loading branch information
1 parent
fa6cc06
commit 93ded9a
Showing
7 changed files
with
68 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ | |
.glide/ | ||
|
||
.idea/ | ||
config.json | ||
|
||
config/ | ||
!config/config.json.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,13 @@ import ( | |
"io/ioutil" | ||
"html/template" | ||
"github.com/RiiConnect24/Mail-Go/patch" | ||
"crypto/rand" | ||
) | ||
|
||
var global patch.Config | ||
var db *sql.DB | ||
var templates *template.Template | ||
var salt []byte | ||
|
||
func logRequest(handler http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
|
@@ -71,7 +73,7 @@ func configHandle(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
patched, err := patch.ModifyNwcConfig(file, db, global) | ||
patched, err := patch.ModifyNwcConfig(file, db, global, salt) | ||
if err != nil { | ||
log.Printf("unable to patch: %v", err) | ||
fmt.Fprintf(w, "It seems your patching went awry. Contact our support email: [email protected].\nError: %v", err) | ||
|
@@ -88,6 +90,27 @@ func configHandle(w http.ResponseWriter, r *http.Request) { | |
} | ||
|
||
func main() { | ||
// Get salt for passwords | ||
saltLocation := "config/salt.bin" | ||
salt, err := ioutil.ReadFile(saltLocation) | ||
if os.IsNotExist(err) { | ||
log.Printf("No salt found. Creating....") | ||
salt = make([]byte, 128) | ||
|
||
_, err := rand.Read(salt) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
err = ioutil.WriteFile("config/salt.bin", salt, os.ModePerm) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} else if err != nil { | ||
panic(err) | ||
} | ||
|
||
|
||
file, err := os.Open("config/config.json") | ||
if err != nil { | ||
panic(err) | ||
|
@@ -150,7 +173,7 @@ func main() { | |
s3.Execute(w, nil) | ||
}) | ||
http.HandleFunc("/patch", configHandle) | ||
|
||
log.Println("Running...") | ||
|
||
// We do this to log all access to the page. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters