summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2026-09-25 19:07:00 -0700
committerRose Hogenson <rosehogenson@posteo.net>2026-09-25 19:07:58 -0700
commit9e3bfeb1e6008cfff220606109662fde329c8c0e (patch)
tree32aa9fee9a3134a02cbbf9b4e0d4cacbf6f7807d /roseh.moe.go
parentExtend write deadline beyond the read deadline (diff)
downloadroseh.moe-9e3bfeb1e6008cfff220606109662fde329c8c0e.tar.zst
Revert "Add an easier way to log in"
This reverts commit b8f2d13664698d999a4154f43e869402cc5cec49.
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/roseh.moe.go b/roseh.moe.go
index 0aa75be..b53f65e 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -832,63 +832,6 @@ func logout(w http.ResponseWriter, r *http.Request) {
}
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
notepadTemplate = template.Must(outlinedTemplate(notepadString))
@@ -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})