From 9e3bfeb1e6008cfff220606109662fde329c8c0e Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 25 Sep 2026 19:07:00 -0700 Subject: Revert "Add an easier way to log in" This reverts commit b8f2d13664698d999a4154f43e869402cc5cec49. --- roseh.moe.go | 59 ----------------------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'roseh.moe.go') diff --git a/roseh.moe.go b/roseh.moe.go index 0aa75be..b53f65e 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -831,63 +831,6 @@ func logout(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "logged out\n") } -var ( - //go:embed templates/otp.html.template - otpString string - otpTemplate = template.Must(outlinedTemplate(otpString)) - - otpMu sync.Mutex - currentOTP string -) - -type otpTemplateArgs struct { - URL string - QR string -} - -func otp(w http.ResponseWriter, r *http.Request) { - buf := make([]byte, 20) - rand.Read(buf) - newOTP := new(strings.Builder) - for i := range 10 { - if i > 0 { - newOTP.WriteString("-") - } - newOTP.WriteString(wordlist.Words[binary.NativeEndian.Uint16(buf[2*i:])&0x1fff]) - } - otpMu.Lock() - currentOTP = newOTP.String() - otpMu.Unlock() - downloadURL := selfURL.String() + "/otp/" + newOTP.String() - if err := otpTemplate.Execute(w, otpTemplateArgs{ - URL: downloadURL, - QR: "/qr.png?" + url.Values{"t": []string{downloadURL}, "s": []string{base64.RawURLEncoding.EncodeToString(mac([]byte(downloadURL), "qr"))}}.Encode(), - }); err != nil { - log.Printf("Warning: otp: %s", err) - } -} - -func otpCode(w http.ResponseWriter, r *http.Request) { - code := r.PathValue("code") - if code == "" { - notFound(w, r) - return - } - matched := false - otpMu.Lock() - if code == currentOTP { - currentOTP = "" - matched = true - } - otpMu.Unlock() - if !matched { - notFound(w, r) - return - } - attachCookie(w) - io.WriteString(w, "logged in\n") -} - var ( //go:embed templates/note.html.template notepadString string @@ -1227,8 +1170,6 @@ func main() { mux.HandleFunc("GET /wormhole/{hole}", wormholeDownload) mux.Handle("GET /login", &timeoutHandler{h: http.HandlerFunc(serveLogin), timeout: 5 * time.Minute}) mux.Handle("POST /login", &timeoutHandler{h: http.HandlerFunc(login), timeout: 5 * time.Minute}) - mux.Handle("GET /otp", &timeoutHandler{h: &authHandler{h: http.HandlerFunc(otp)}, timeout: 5 * time.Minute}) - mux.Handle("GET /otp/{code}", &timeoutHandler{h: http.HandlerFunc(otpCode), timeout: 5 * time.Minute}) mux.Handle("GET /logout", &timeoutHandler{h: &authHandler{h: http.HandlerFunc(logout), noRedirect: true}, timeout: 5 * time.Minute}) mux.Handle("GET /notepad", &timeoutHandler{h: &authHandler{h: http.HandlerFunc(notepad)}, timeout: 5 * time.Minute}) mux.Handle("POST /notepad", &timeoutHandler{h: &authHandler{h: http.HandlerFunc(autosave), noRedirect: true}, timeout: 5 * time.Minute}) -- cgit v1.3.1