Closed crimsonhawk47 closed 1 year ago
The docs ask you to add wrap-authentication here:
wrap-authentication
(defn wrap-base [{:keys [metrics site-defaults-config cookie-session] :as opts}] (fn [handler] (cond-> ((:middleware env/defaults) handler opts) true (defaults/wrap-defaults (assoc-in site-defaults-config [:session :store] (cookie/cookie-store cookie-session))) true (wrap-authentication (session-backend)))))
But if wrap-authentication comes after wrap-defaults, there is no session to be read. This is the expected example:
wrap-defaults
(defn wrap-base [{:keys [metrics site-defaults-config cookie-secret] :as opts}] (let [cookie-store (cookie/cookie-store {:key (.getBytes ^String cookie-secret)})] (fn [handler] (cond-> ((:middleware env/defaults) handler opts) true (wrap-authentication (session-backend)) true (defaults/wrap-defaults (assoc-in site-defaults-config [:session :store] cookie-store))))))
Thanks, that's a good catch. Just updated the docs here.
The docs ask you to add
wrap-authentication
here:But if
wrap-authentication
comes afterwrap-defaults
, there is no session to be read. This is the expected example: