diff options
author | Tim <contact@bytim.eu> | 2025-05-10 10:59:30 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-05-10 10:59:30 +0200 |
commit | 77594fd2b62e4ea3e6a55fed2dabcce50e618bd3 (patch) | |
tree | 5ddfa7589b5d9a46dbd40d5eea49c3e782c22d1a /src/chef/utils.clj | |
parent | 79e32a55801fc53c8d60843c6676ca05cc899299 (diff) | |
download | chef-77594fd2b62e4ea3e6a55fed2dabcce50e618bd3.tar.xz chef-77594fd2b62e4ea3e6a55fed2dabcce50e618bd3.zip |
Add oauth for admin interface
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r-- | src/chef/utils.clj | 15 |
1 files changed, 15 insertions, 0 deletions
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)))) |