aboutsummaryrefslogtreecommitdiff
path: root/status.go
diff options
context:
space:
mode:
authorCaroline Larimore <caroline@larimo.re>2025-01-22 00:33:35 -0800
committerCaroline Larimore <caroline@larimo.re>2025-01-22 00:33:35 -0800
commit623aecb436ddd1a5746ed712a64fef23462a317f (patch)
treec0cbc7ce2ca7411a0d0e5a41426d1539693d3423 /status.go
parent65f782661d27993898ba6571c00df24e7c19c9fa (diff)
Added endpoint to generate hash (still sketchy asf)
Diffstat (limited to 'status.go')
-rw-r--r--status.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/status.go b/status.go
index 92561ce..8ef5301 100644
--- a/status.go
+++ b/status.go
@@ -83,6 +83,23 @@ func main() {
deny(w)
})
+ http.HandleFunc("/generate-hash", func(w http.ResponseWriter, r *http.Request) {
+ username, password, ok := r.BasicAuth()
+ if ok {
+ hash, err := bcrypt.GenerateFromPassword([]byte(username+password), 0)
+ if err != nil {
+ http.Error(w, "Failed to generate hash", http.StatusInternalServerError)
+ return
+ }
+
+ log.Print(string(hash))
+ w.Write([]byte("Hash successfully generated (output to server log for some semblance of security)"))
+ return
+ }
+
+ deny(w)
+ })
+
log.Fatal(http.ListenAndServe(":"+os.Args[1], nil))
}