From 77594fd2b62e4ea3e6a55fed2dabcce50e618bd3 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 10 May 2025 10:59:30 +0200 Subject: Add oauth for admin interface --- src/chef/utils.clj | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/chef/utils.clj (limited to 'src/chef/utils.clj') diff --git a/src/chef/utils.clj b/src/chef/utils.clj new file mode 100644 index 0000000..a721617 --- /dev/null +++ b/src/chef/utils.clj @@ -0,0 +1,15 @@ +(ns chef.utils + (:require [ring.util.response :as ruresp])) + +(defn gen-page [title & content] + [:html + [:head + [:meta {:name "viewport" :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"}] + [:title title]] + (apply conj [:body] content [[:script {:src "/static/htmx.js"}]])]) + +(defmacro auth-only [request & body] + `(if (some? (get-in ~request [:session :oauth-token])) + (do ~@body) + ~(-> (ruresp/response "Unauthorized.") + (ruresp/status 401)))) -- cgit v1.2.3