Skip to content

Commit

Permalink
LPK-6546: Check session for expiry when authorizing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenttila committed Jun 6, 2023
1 parent 66deb80 commit d5cf2ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject lupapiste/document-search-commons "1.0.7"
(defproject lupapiste/document-search-commons "1.1.0"
:description "Common document search related code shared between lupadoku and onkalo applications"
:url "https://www.lupapiste.fi"
:license {:name "European Union Public License"
Expand Down Expand Up @@ -29,7 +29,7 @@
[cljsjs/openlayers "4.4.1-1"]
[tailrecursion/cljson "1.0.7"]
[alandipert/storage-atom "2.0.1"]]
:profiles {:provided {:dependencies [[lupapiste/commons "4.1.1" :exclusions [commons-logging commons-codec]]]}}
:profiles {:provided {:dependencies [[lupapiste/commons "5.0.0" :exclusions [commons-logging commons-codec]]]}}
:plugins [[deraen/lein-sass4clj "0.3.1"]]
:source-paths ["src/clj" "src/cljc" "src/cljs"]
:test-paths ["test/clj" "test/cljc"]
Expand Down
7 changes: 4 additions & 3 deletions src/clj/search_commons/authorization.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns search-commons.authorization
(:require [clojure.set :refer [intersection]]
(:require [lupapiste-commons.ring.session-timeout :as commons-session-timeout]
[search-commons.i18n :refer [t]]))


Expand Down Expand Up @@ -27,8 +27,9 @@
(defn wrap-user-authorization [handler tr-data required-roles & [redirect-path]]
(fn [request]
(let [lang (or (keyword (get-in request [:headers "Accept-Language"])) :fi)]
(if-let [user (or (get-in request [:session :user])
(:autologin-user request))]
(if-let [user (and (not (commons-session-timeout/session-expired? request))
(or (get-in request [:session :user])
(:autologin-user request)))]
(if (not (every? nil? (mapv (fn [role] (user-is-authorized? user role)) required-roles)))
(let [response (-> (assoc request :user user)
(handler))]
Expand Down

0 comments on commit d5cf2ae

Please sign in to comment.