summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go24
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})