summaryrefslogtreecommitdiff
path: root/srv/src/http/csrf.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-24 17:27:03 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-24 17:27:03 -0600
commit159638084e167047b86fd65382f50cd099d4eb48 (patch)
treed4653540894da749726f4f8be988fe6df8d195a7 /srv/src/http/csrf.go
parent88ebaeda8f02e2c89dac44809fffb1f9ebb71bd0 (diff)
Fix CSRF loading on static GET pages
Diffstat (limited to 'srv/src/http/csrf.go')
-rw-r--r--srv/src/http/csrf.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/srv/src/http/csrf.go b/srv/src/http/csrf.go
index 1c80dee..7a45269 100644
--- a/srv/src/http/csrf.go
+++ b/srv/src/http/csrf.go
@@ -57,3 +57,22 @@ func checkCSRFMiddleware(h http.Handler) http.Handler {
h.ServeHTTP(rw, r)
})
}
+
+func (a *api) getCSRFTokenHandler() http.Handler {
+
+ return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
+
+ csrfTok, err := apiutil.GetCookie(r, csrfTokenCookieName, "")
+
+ if err != nil {
+ apiutil.InternalServerError(rw, r, err)
+ return
+ }
+
+ apiutil.JSONResult(rw, r, struct {
+ CSRFToken string
+ }{
+ CSRFToken: csrfTok,
+ })
+ })
+}