Trying to work around Caddy not passing POST

This commit is contained in:
Neale Pickett 2022-09-10 08:47:41 -06:00
parent 35a30f21d4
commit d10c46c434
2 changed files with 9 additions and 7 deletions

View File

@ -27,13 +27,9 @@ var successHtml []byte
func authenticationValid(username, password string) bool { func authenticationValid(username, password string) bool {
c := crypt.SHA256.New() c := crypt.SHA256.New()
fmt.Println("checking", username, password)
if crypted, ok := cryptedPasswords[username]; ok { if crypted, ok := cryptedPasswords[username]; ok {
fmt.Println(username, password, crypted)
if err := c.Verify(crypted, []byte(password)); err == nil { if err := c.Verify(crypted, []byte(password)); err == nil {
return true return true
} else {
log.Println(err)
} }
} }
return false return false
@ -127,7 +123,6 @@ func main() {
if len(parts) >= 2 { if len(parts) >= 2 {
username := parts[0] username := parts[0]
password := parts[1] password := parts[1]
fmt.Println(username, password)
cryptedPasswords[username] = password cryptedPasswords[username] = password
} }
} }

View File

@ -25,9 +25,16 @@
async function login(evt) { async function login(evt) {
evt.preventDefault() evt.preventDefault()
let data = new FormData(evt.target)
let username = data.get("username")
let password = data.get("password")
let headers = new Headers({
"Authorization": "Basic " + btoa(username + ":" + password),
})
let req = await fetch(evt.target.action, { let req = await fetch(evt.target.action, {
method: evt.target.method, method: "GET",
body: new FormData(evt.target), headers: headers,
credentials: "same-origin", credentials: "same-origin",
}) })
if (! req.ok) { if (! req.ok) {