Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(sipi): SIPI returns 404 instead of images if cookie is invalid (D…
  • Loading branch information
BalduinLandolt committed Aug 2, 2022
1 parent 49f1638 commit eb797f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sipi/scripts/sipi.init.lua
Expand Up @@ -40,14 +40,14 @@ function pre_flight(prefix, identifier, cookie)

knora_cookie_header = nil

if cookie ~='' then
if cookie ~= '' then

-- tries to extract the Knora session name and id from the cookie:
-- gets the digits between "sid=" and the closing ";" (only given in case of several key value pairs)
-- returns nil if it cannot find it
session = get_session_id(cookie)

if session == nil then
if session == nil or session["name"] == nil or session["id"] == nil then
-- no session could be extracted
server.log("cookie key is invalid: " .. cookie, server.loglevel.LOG_ERR)
else
Expand All @@ -74,7 +74,7 @@ function pre_flight(prefix, identifier, cookie)
end
server.log("webapi_port: " .. webapi_port, server.loglevel.LOG_DEBUG)

knora_url = 'http://' .. webapi_hostname .. ':' .. webapi_port .. '/admin/files/' .. prefix .. '/' .. identifier
knora_url = 'http://' .. webapi_hostname .. ':' .. webapi_port .. '/admin/files/' .. prefix .. '/' .. identifier

-- print("knora_url: " .. knora_url)
server.log("pre_flight - knora_url: " .. knora_url, server.loglevel.LOG_DEBUG)
Expand Down Expand Up @@ -117,7 +117,8 @@ function pre_flight(prefix, identifier, cookie)
-- server.log("pre_flight - restricted view settings - watermark: " .. tostring(response_json.restrictedViewSettings.watermark), server.loglevel.LOG_DEBUG)

if response_json.restrictedViewSettings.size ~= nil then
server.log("pre_flight - restricted view settings - size: " .. tostring(response_json.restrictedViewSettings.size), server.loglevel.LOG_DEBUG)
server.log("pre_flight - restricted view settings - size: " ..
tostring(response_json.restrictedViewSettings.size), server.loglevel.LOG_DEBUG)
restrictedViewSize = response_json.restrictedViewSettings.size
else
server.log("pre_flight - using default restricted view size", server.loglevel.LOG_DEBUG)
Expand All @@ -140,4 +141,5 @@ function pre_flight(prefix, identifier, cookie)
return 'deny'
end
end

-------------------------------------------------------------------------------

0 comments on commit eb797f0

Please sign in to comment.