diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-09-25 19:08:16 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-09-25 19:08:44 -0700 |
| commit | 8e0696de6504b93b9a3a20976d5eb676cdd59b24 (patch) | |
| tree | 167c631e2f65f89c88ad57e8ac2d3d75ec2f45c5 | |
| parent | Revert "Add an easier way to log in" (diff) | |
| download | roseh.moe-8e0696de6504b93b9a3a20976d5eb676cdd59b24.tar.zst | |
Revert "Add a way to log out"
This reverts commit 766b7586fde4f1321e2c23428001c2dd67576dd4.
| -rw-r--r-- | roseh.moe.go | 24 |
1 files 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}) |
