Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make Sipi handle multiple KnoraAuthentication* cookies correctly (DEV-2271) #2713

Merged
merged 3 commits into from Jun 20, 2023

Conversation

seakayone
Copy link
Collaborator

@seakayone seakayone commented Jun 20, 2023

Pull Request Checklist

Task Description/Number

Issue Number: DEV-2271

  • Cookies in production are visible for and Sipi could not handle multiple cookies
  • Implement _get_jwt_token_from_cookie by parsing the cookies header value, because Sipis server.cookies implementation is broken (only returns a single cookie value which contains the others even if multiple cookies are present)
  • Extract the correct cookie from the header
  • Added some new lines to the tableToString function which is currently used in debug logging only. Added a str_splitString because Lua does not provide one. Used it for prototyping but ended up not using it, still thought it might be useful addition to our strings file.

Basic Requirements

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • fix: represents bug fixes
  • refactor: represents production code refactoring
  • feat: represents a new feature
  • docs: documentation changes (no production code change)
  • chore: maintenance tasks (no production code change)
  • test: all about tests: adding, refactoring tests (no production code change)
  • other... Please describe:

Does this PR introduce a breaking change?

  • Yes
  • No
  • Maybe (not 100% sure => check with FE)

Does this PR change client-test-data?

  • Yes (don't forget to update the JS-LIB team about the change)
  • No

…ly (DEV-2271)

* Cookies in production are visible for and Sipi could not handle multiple cookies
* Implement _get_jwt_token_from_cookie by parsing the cookies header value,
  because Sipis server.cookies implementation is broken

https://linear.app/dasch/issue/DEV-2271/sometimes-you-get-a-404-error-when-you-want-to-open-a-media-file
@linear
Copy link

linear bot commented Jun 20, 2023

DEV-2271 Sometimes you get a 404 Error when you want to open a media file

Screenshot 2023-06-12 at 07.07.14.png

Happens mostly on Chrome, when the cache and cookies aren't cleaned

Good example projects = Fagottini and Aura-Effizienz.

Type of media file: videos, PDFs, sometimes with ZIP archives and images

Happens in all environments (prod, staging, dev, test)

Screenshot 2023-06-12 at 08.39.44.png

Screenshot 2023-06-12 at 08.40.20.png

From Flavie's computer:

VIDEO

Screenshot_video.png

message_invalid-token.png

PDF: the same message "Invalid token, unable to decode jwt" is displayed when double-clicking on the 401 error

Screenshot_pdf.png

URL on prod: https://admin.dasch.swiss/project/hp1UIqpKS_Kc7j0c5wh5jA/ontology/fagottino/Video

@seakayone seakayone self-assigned this Jun 20, 2023
@seakayone seakayone requested review from mpro7, BalduinLandolt and mdelez and removed request for mpro7 June 20, 2023 07:11
@seakayone seakayone marked this pull request as ready for review June 20, 2023 07:12
Copy link
Collaborator

@BalduinLandolt BalduinLandolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand the implications of the changes you did to strings.lua, but I trust you on that, and otherwise it looks good

@codecov
Copy link

codecov bot commented Jun 20, 2023

Codecov Report

Patch coverage: 61.92% and project coverage change: +64.48 🎉

Comparison is base (ee3cddc) 17.89% compared to head (d730012) 82.38%.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2713       +/-   ##
===========================================
+ Coverage   17.89%   82.38%   +64.48%     
===========================================
  Files         277      279        +2     
  Lines       28855    28936       +81     
===========================================
+ Hits         5165    23838    +18673     
+ Misses      23690     5098    -18592     
Impacted Files Coverage Δ
...esponder/standoffmessages/StandoffMessagesV2.scala 54.16% <0.00%> (+44.51%) ⬆️
...knora/webapi/responders/v1/ValuesResponderV1.scala 91.09% <ø> (+89.96%) ⬆️
...ra/webapi/responders/v2/ResourcesResponderV2.scala 88.26% <ø> (+86.99%) ⬆️
...knora/webapi/responders/v2/SearchResponderV2.scala 91.81% <ø> (+85.40%) ⬆️
...ora/webapi/responders/v2/StandoffResponderV2.scala 86.21% <ø> (+82.97%) ⬆️
.../slice/admin/api/model/ProjectExportResponse.scala 0.00% <0.00%> (ø)
...slice/admin/domain/service/ProjectADMService.scala 96.77% <0.00%> (-3.23%) ⬇️
...a/webapi/store/iiif/impl/IIIFServiceSipiImpl.scala 50.74% <ø> (+50.00%) ⬆️
...ice/admin/api/service/ProjectsADMRestService.scala 60.00% <7.69%> (-17.78%) ⬇️
...rg/knora/webapi/routing/admin/ProjectsRouteZ.scala 90.65% <14.28%> (-4.50%) ⬇️
... and 21 more

... and 172 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@seakayone
Copy link
Collaborator Author

I don't fully understand the implications of the changes you did to strings.lua, but I trust you on that, and otherwise it looks good

Added some new lines to the tableToString function which is currently used in debug logging only.
Added a str_splitString because Lua does not provide one. Used it for prototyping but ended up not using it, still thought it might be useful addition to our strings file.

@BalduinLandolt
Copy link
Collaborator

I don't fully understand the implications of the changes you did to strings.lua, but I trust you on that, and otherwise it looks good

Added some new lines to the tableToString function which is currently used in debug logging only. Added a str_splitString because Lua does not provide one. Used it for prototyping but ended up not using it, still thought it might be useful addition to our strings file.

makes sense, thanks for the explanation :)

Copy link
Contributor

@mdelez mdelez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@seakayone seakayone enabled auto-merge (squash) June 20, 2023 08:04
@seakayone seakayone merged commit 1330d2b into main Jun 20, 2023
13 checks passed
@seakayone seakayone deleted the multiple-cookies-sipi branch June 20, 2023 08:27
@seakayone seakayone restored the multiple-cookies-sipi branch June 21, 2023 13:19
@seakayone seakayone deleted the multiple-cookies-sipi branch June 22, 2023 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants