mirror of
https://github.com/riwiwa/muzi.git
synced 2026-02-28 11:56:57 -08:00
add CSRF protection, add cookie security
This commit is contained in:
@@ -204,6 +204,8 @@ func createAccount(w http.ResponseWriter, r *http.Request) {
|
||||
Value: sessionID,
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Secure: true,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
MaxAge: 86400 * 30, // 30 days
|
||||
})
|
||||
http.Redirect(w, r, "/profile/"+username, http.StatusSeeOther)
|
||||
@@ -248,6 +250,8 @@ func loginSubmit(w http.ResponseWriter, r *http.Request) {
|
||||
Value: sessionID,
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Secure: true,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
MaxAge: 86400 * 30, // 30 days
|
||||
})
|
||||
http.Redirect(w, r, "/profile/"+username, http.StatusSeeOther)
|
||||
@@ -503,5 +507,6 @@ func Start() {
|
||||
r.Post("/import/lastfm", importLastFMHandler)
|
||||
r.Get("/import/lastfm/progress", importLastFMProgressHandler)
|
||||
fmt.Printf("WebUI starting on %s\n", addr)
|
||||
http.ListenAndServe(addr, r)
|
||||
prot := http.NewCrossOriginProtection()
|
||||
http.ListenAndServe(addr, prot.Handler(r))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user