summaryrefslogtreecommitdiff
path: root/middleware/auth.go
diff options
context:
space:
mode:
authorhaturatu <taro@eyes4you.org>2025-10-13 00:45:26 +0900
committerhaturatu <taro@eyes4you.org>2025-10-13 00:45:26 +0900
commit5fde794315efd7c8146e7b69b9e7d05132a2e3df (patch)
tree741ee8f220e3b65374e5c67ed75700321249002f /middleware/auth.go
parentff0668aa216c6645e2bb26e0a7ef5091a62a84ba (diff)
a
Diffstat (limited to 'middleware/auth.go')
-rw-r--r--middleware/auth.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/middleware/auth.go b/middleware/auth.go
index e4f096b..5025f32 100644
--- a/middleware/auth.go
+++ b/middleware/auth.go
@@ -154,4 +154,16 @@ func AdminMiddleware(next http.Handler) http.Handler {
logging.SecurityLog.Info("ADMIN ACCESS GRANTED", "user", user.Username, "path", r.URL.Path, "ip", ip)
next.ServeHTTP(w, r)
})
+}
+
+// HandleOptions is a middleware that handles pre-flight OPTIONS requests.
+// This should be placed before the CSRF middleware.
+func HandleOptions(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Method == http.MethodOptions {
+ w.WriteHeader(http.StatusOK)
+ return
+ }
+ next.ServeHTTP(w, r)
+ })
} \ No newline at end of file