Should fix most of the authentication issues

This commit is contained in:
2023-09-05 23:08:22 -07:00
parent a6e4080746
commit a56d3b0b84
22 changed files with 506 additions and 179 deletions

View File

@@ -179,7 +179,8 @@
[handler]
(fn [request]
(let [x-clients (-> request :session :client-selection)
identity (-> request :session :identity)
identity (or (-> request :identity)
(-> request :session :identity))
ideal-ids (set (cond
(or (= :all x-clients)
(nil? x-clients))
@@ -235,6 +236,26 @@
(into new-session)
(assoc :client-selection x-clients))))))))
(defn wrap-gunzip-jwt
[handler]
(fn [{:keys [session] :as request}]
(let [request (if-let [gz-clients (some-> request :identity :gz-clients)]
(try
(assoc-in request [:identity :user/clients]
(auth/gunzip gz-clients))
(catch Exception e
(alog/error :cant-gunzip-clients
:error e)
request))
request)]
(handler request))))
#_(defn wrap-pprint-session
[handler]
(fn [request]
(clojure.pprint/pprint (:session request))
(handler request)))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(def app
(-> route-handler
@@ -242,16 +263,19 @@
(wrap-guess-route)
(wrap-hydrate-clients)
(wrap-store-client-in-session)
(wrap-gunzip-jwt)
(wrap-authorization auth-backend)
(wrap-authentication auth-backend
(session-backend {:authfn (fn [auth]
(dissoc auth :exp))}))
#_(wrap-pprint-session)
(wrap-idle-session-timeout)
(wrap-session {:store (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)