This commit is contained in:
lbenedar
2026-03-06 14:58:38 +03:00
parent 94345eff97
commit b6cdb2b860
9 changed files with 24 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ package main
import (
"fmt"
"net/http"
"github.com/justinas/nosurf"
)
func secureHeaders(next http.Handler) http.Handler {
@@ -49,3 +51,14 @@ func (app *application) requireAuthentication(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}
func noSurf(next http.Handler) http.Handler {
csrfHanlder := nosurf.New(next)
csrfHanlder.SetBaseCookie(http.Cookie{
HttpOnly: true,
Path: "/",
Secure: true,
})
return csrfHanlder
}