summaryrefslogtreecommitdiff
path: root/csrf/csrf.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2024-10-17 00:27:08 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2024-10-17 00:27:08 +0200
commit869fb9691f877116d5b15a92de006d0daf4d70e5 (patch)
tree2493c72172d5817ec9deec36229a84b687eb3190 /csrf/csrf.go
parent6fc180ba6d9bc5c32340466988d9e26f8d6e3c5c (diff)
downloadgosten-869fb9691f877116d5b15a92de006d0daf4d70e5.tar.gz
gosten-869fb9691f877116d5b15a92de006d0daf4d70e5.tar.bz2
gosten-869fb9691f877116d5b15a92de006d0daf4d70e5.zip
Restructure and change to chi as muxing framework
Diffstat (limited to '')
-rw-r--r--csrf/csrf.go (renamed from csrf.go)8
1 files changed, 4 insertions, 4 deletions
diff --git a/csrf.go b/csrf/csrf.go
index 4539825..18fdb81 100644
--- a/csrf.go
+++ b/csrf/csrf.go
@@ -1,4 +1,4 @@
-package main
+package csrf
import (
"html/template"
@@ -8,12 +8,12 @@ import (
"github.com/gorilla/securecookie"
)
-func csrfHandler(next http.Handler) http.Handler {
+func Handler() func(http.Handler) http.Handler {
return csrf.Protect(
securecookie.GenerateRandomKey(32),
csrf.SameSite(csrf.SameSiteStrictMode),
csrf.FieldName("csrf.csrffield"), // should match the structure in `Csrf`
- )(next)
+ )
}
// Csrf handles the CSRF data for a form.
@@ -26,6 +26,6 @@ func (c *Csrf) SetCsrfField(r *http.Request) {
c.CsrfField = csrf.TemplateField(r)
}
-type WithCsrf interface {
+type Enabled interface {
SetCsrfField(r *http.Request)
}