From 9615350eb9e81d094b2506bcf95c5e1a31024cb4 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 11 Jan 2023 15:32:08 -0800 Subject: [PATCH] One more set of fixes for new approach. --- src/clj/auto_ap/handler.clj | 10 ++++++++-- src/clj/auto_ap/routes/auth.clj | 2 +- src/clj/auto_ap/ssr/admin.clj | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/clj/auto_ap/handler.clj b/src/clj/auto_ap/handler.clj index 683c1023..167bb911 100644 --- a/src/clj/auto_ap/handler.clj +++ b/src/clj/auto_ap/handler.clj @@ -14,6 +14,7 @@ [buddy.auth.backends.session :refer [session-backend]] [buddy.auth.backends.token :refer [jws-backend]] [buddy.auth.middleware :refer [wrap-authentication wrap-authorization]] + [clojure.string :as str] [clojure.tools.logging :as log] [compojure.core :refer [ANY context defroutes GET routes]] @@ -25,6 +26,7 @@ [ring.middleware.params :refer [wrap-params]] [ring.middleware.reload :refer [wrap-reload]] [ring.middleware.session :refer [wrap-session]] + [ring.middleware.session.cookie :refer [cookie-store]] [ring.util.response :as response] [unilog.context :as lc])) @@ -97,9 +99,13 @@ (wrap-authorization auth-backend ) (wrap-authentication auth-backend - (session-backend)) + (session-backend {:authfn (fn [auth] + (dissoc auth :exp))})) - (wrap-session) + (wrap-session {:store (ring.middleware.session.cookie/cookie-store + {:key + (byte-array + [42, 52, -31, 105, -126, -33, -118, -69, -82, -59, -15, -69, -38, 103, -102, -1])} )}) (wrap-reload) (wrap-params) (mp/wrap-multipart-params) diff --git a/src/clj/auto_ap/routes/auth.clj b/src/clj/auto_ap/routes/auth.clj index 01decba7..aac7b7ef 100644 --- a/src/clj/auto_ap/routes/auth.clj +++ b/src/clj/auto_ap/routes/auth.clj @@ -57,7 +57,7 @@ {:status 301 :headers {"Location" (str "/?jwt=" jwt)} - :session {:identity auth}}) + :session {:identity (dissoc auth :exp)}}) {:status 401 :body "Couldn't authenticate"})) (catch Exception e diff --git a/src/clj/auto_ap/ssr/admin.clj b/src/clj/auto_ap/ssr/admin.clj index 46163bd1..9ab93f21 100644 --- a/src/clj/auto_ap/ssr/admin.clj +++ b/src/clj/auto_ap/ssr/admin.clj @@ -158,7 +158,9 @@ request) (try (let [entity-id (Long/parseLong (or (some-> (:entity-id form-params) not-empty) - (:entity-id params))) + (:entity-id params) + (get params "entity-id") + (get form-params "entity-id"))) history (->> (d/q '[:find ?a2 ?v (pull ?tx [:db/txInstant :audit/user :db/id]) ?ad :in $ $$ ?i