From 8e0696de6504b93b9a3a20976d5eb676cdd59b24 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 25 Sep 2026 19:08:16 -0700 Subject: Revert "Add a way to log out" This reverts commit 766b7586fde4f1321e2c23428001c2dd67576dd4. --- roseh.moe.go | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/roseh.moe.go b/roseh.moe.go index b53f65e..a7169a7 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -695,10 +695,13 @@ func makeToken() string { return base64.RawURLEncoding.EncodeToString(append(t, mac(t, "auth")...)) } -func makeCookie(val string) *http.Cookie { - return &http.Cookie{ +const cookieExpiration = 7 * 24 * time.Hour +const authCookieName = "a" + +func attachCookie(w http.ResponseWriter) { + http.SetCookie(w, &http.Cookie{ Name: authCookieName, - Value: val, + Value: makeToken(), Path: "/", Domain: selfURL.Hostname(), Expires: time.Now().Add(cookieExpiration), @@ -706,14 +709,7 @@ func makeCookie(val string) *http.Cookie { HttpOnly: true, SameSite: http.SameSiteStrictMode, Partitioned: true, - } -} - -const cookieExpiration = 7 * 24 * time.Hour -const authCookieName = "a" - -func attachCookie(w http.ResponseWriter) { - http.SetCookie(w, makeCookie(makeToken())) + }) } func cookieAuth(w http.ResponseWriter, r *http.Request) bool { @@ -826,11 +822,6 @@ func login(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, redirect, http.StatusSeeOther) } -func logout(w http.ResponseWriter, r *http.Request) { - http.SetCookie(w, makeCookie("!")) - io.WriteString(w, "logged out\n") -} - var ( //go:embed templates/note.html.template notepadString string @@ -1170,7 +1161,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 /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}) mux.Handle("GET /cmd/{$}", &timeoutHandler{h: http.HandlerFunc(cmdIndex), timeout: 5 * time.Minute}) -- cgit v1.3.1