Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(sipi): cookie parsing can cause an error which leads to 404 for i…
…mages (DEV-1135) (#2134)

* fix: potentially fix lua issue when parsing cookie

* chore: skip test for release action
  • Loading branch information
BalduinLandolt committed Jul 28, 2022
1 parent d5b48db commit bd023a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
45 changes: 19 additions & 26 deletions .github/workflows/main.yml
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
schedule:
# run every midnight (on main) so that the first compile of the day from main is cached
- cron: '0 0 * * *'
- cron: "0 0 * * *"
push:
release:
types: [published]
Expand All @@ -26,8 +26,8 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
distribution: "temurin"
java-version: "17"
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand All @@ -48,8 +48,8 @@ jobs:
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
# ------------------------------------------
# ------------------------------------------
# ------------------------------------------
# ------------------------------------------
client-test-data-tests:
name: Run client-test-data
runs-on: ubuntu-latest
Expand All @@ -67,8 +67,8 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
distribution: "temurin"
java-version: "17"
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand All @@ -95,8 +95,8 @@ jobs:
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
# ------------------------------------------
# ------------------------------------------
# ------------------------------------------
# ------------------------------------------
upgrade-integration-tests:
name: Upgrade Integration Tests
runs-on: ubuntu-latest
Expand All @@ -114,8 +114,8 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
distribution: "temurin"
java-version: "17"
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand All @@ -132,7 +132,7 @@ jobs:
# if: failure()
uses: jwalton/gh-docker-logs@v1
with:
shell: '/bin/sh'
shell: "/bin/sh"
- name: cleanup before cache
shell: bash
run: |
Expand Down Expand Up @@ -187,12 +187,7 @@ jobs:
# publish only on release
publish:
name: Publish (on release only)
needs: [
compile,
client-test-data-tests,
upgrade-integration-tests,
docs-build-test
]
needs: [compile]
runs-on: ubuntu-latest
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
steps:
Expand All @@ -209,8 +204,8 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
distribution: "temurin"
java-version: "17"
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand Down Expand Up @@ -255,9 +250,7 @@ jobs:
# deploy documentation only on release
deploy-docs:
name: Deploy docs (on release only)
needs: [
docs-build-test
]
needs: [docs-build-test]
runs-on: ubuntu-latest
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
steps:
Expand All @@ -282,7 +275,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
CUSTOM_DOMAIN: docs-api.dasch.swiss
REQUIREMENTS: docs/requirements.txt

fmtcheck:
name: Check Formating
runs-on: ubuntu-latest
Expand All @@ -300,8 +293,8 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
distribution: "temurin"
java-version: "17"
- name: add docker compose v2
run: |
mkdir -p ~/.docker/cli-plugins/
Expand Down
12 changes: 8 additions & 4 deletions sipi/scripts/get_knora_session.lua
@@ -1,7 +1,7 @@
-- * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
-- * SPDX-License-Identifier: Apache-2.0

basexx = require( "basexx" )
basexx = require("basexx")

-------------------------------------------------------------------------------
-- This function is called from the route to get the Knora session id from the cookie.
Expand Down Expand Up @@ -32,7 +32,7 @@ function get_session_id(cookie)
send_error(500, "KNORA_WEBAPI_KNORA_API_EXTERNAL_PORT not set")
return nil
end

host_port = webapi_hostname .. ':' .. webapi_port
server.log("host_port: " .. host_port, server.loglevel.LOG_DEBUG)

Expand All @@ -42,7 +42,7 @@ function get_session_id(cookie)





-- tries to extract the Knora session id from the cookie:
-- gets the digits between "sid=" and the closing ";" (only given in case of several key value pairs)
Expand All @@ -51,7 +51,11 @@ function get_session_id(cookie)
-- returns nil if it cannot find the session id (pattern does not match)
server.log("extracted cookie: " .. cookie, server.loglevel.LOG_DEBUG)
local session_id = string.match(cookie, "KnoraAuthentication" .. host_port_base32 .. "=([^%s;]+)")
server.log("extracted session_id: " .. session_id, server.loglevel.LOG_DEBUG)
if session_id == nil then
server.log("no session_id could be extracted from cookie: " .. cookie, server.loglevel.LOG_DEBUG)
else
server.log("extracted session_id: " .. session_id, server.loglevel.LOG_DEBUG)
end

local session = {}
session["id"] = session_id
Expand Down

0 comments on commit bd023a5

Please sign in to comment.