Koha-clms/Koha/REST/V1
Tomas Cohen Arazi bc82200948 Bug 24862: Handle annonymous sessions gracefuly
This patch introduces code to detect (cookie) annonymous sessions and
act as expected.

Right now, as check_cookie_auth is not passed the required permissions
(because there aren't always required permissions, and the code to check
permissions is shared with other authentication mechanisms) it returns
'ok' and the session id. This use case was overlooked when this was
coded, and yeilds unexpected error codes (500) when the user logs out
and the annonymous session cookie is used to hit the API. The end result
doesn't pose any security issue (i.e. the resource access is rejected)
but the returned error code is not correct and should be fixed.

This patch verifies for an anonymous session (and avoids querying the
corresponding patron) and then verifies if there is an authorization
config on the route and if the patron object is defined.

To test:
1. Apply the tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t
=> FAIL: Tests fail, 500 instead of the expected 401
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Repeat the original 'steps to reproduce' from the bug report using
   the browser
=> SUCCESS: Problem solved!
6. Sign off :-D

Sponsored-by: ByWater Solutions
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit de07356028)

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>

(cherry picked from commit 99a3d1193e)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
2020-06-30 21:19:22 +02:00
..
Acquisitions Bug 19661: Add and change properties and parameters to conform to the funds RFC. 2019-03-22 19:40:37 +00:00
Patrons Bug 22600: Add 'interface' to accountlines 2019-04-10 19:43:11 +00:00
Auth.pm Bug 24862: Handle annonymous sessions gracefuly 2020-06-30 21:19:22 +02:00
Biblios.pm Bug 15496: (QA follow-up) Change success status on api 2019-04-26 12:06:58 +00:00
Checkouts.pm Bug 17003: (follow-up) Update definitions according to voted RFC 2019-07-25 14:12:55 +02:00
Cities.pm Revert "Bug 22026: Removed 'use Modern::Perl;' from Koha::REST::classes" 2019-02-26 11:04:08 -05:00
Holds.pm Bug 22206: (follow-up) Voted RFC changes 2019-03-15 19:35:30 +00:00
Illrequests.pm Bug 21460: (follow-up) Fix bugs found in QA 2019-04-25 10:46:56 +00:00
Items.pm Bug 16825: Add API route for getting an item 2019-09-13 15:03:15 +02:00
Library.pm Bug 16497: (follow-up) Adapt to existing guidelines and RFC 2019-02-19 13:52:14 +00:00
OAuth.pm Revert "Bug 22026: Removed 'use Modern::Perl;' from Koha::REST::classes" 2019-02-26 11:04:08 -05:00
Patrons.pm Bug 22729: Adapt /patrons controller code to the change 2019-04-25 10:06:44 +00:00
Stage.pm Revert "Bug 22026: Removed 'use Modern::Perl;' from Koha::REST::classes" 2019-02-26 11:04:08 -05:00
Static.pm Bug 22835: (follow-up) Remove comented code 2020-02-06 21:19:32 +00:00