Koha-clms/Koha/REST/V1
Lari Taskula 7ba53849d5 Bug 28907: REST - Drop support for allow-owner functionality
...and allow-guarantor functionality. Replaced by $c->auth->public($patron_id)
and/or $c->auth->public_guarantor($patron_id), where $patron_id is the patron's
id that owns the requested resource.

Old method, was applicable to both privileged and public routes:

  api/v1/swagger/paths/route.yaml

  x-koha-authorization:
    allow-owner: true
    allow-guarantor: true

New method, use public routes with no x-koha-authorization:

  GET /public/route/{patron_id}
  Koha/REST/V1/Controller#public_action:

  sub public_action {
      my $c = shift->openapi->valid_input or return;
      my $patron_id = $c->param( 'patron_id' );
      try {
          # Throws an exception that will render a response of 401 if not
          # authenticated and 403 if trying to access another user's resources
          $c->auth->public($patron_id); #or $c->auth->public_guarantor($patron_id)
          ...
          # other code
          ...
      }
      catch {
          $c->unhandled_exception($_);
      }
  }

  Another example of retrieving $patron_id when patron_id is not a request
  parameter:
  GET /public/another/object/{another_object_id}

  my $patron_id = Another::Object->find($another_object_id)->borrowernumber;
  try {
      # 403 if $another_object_id does not belong to API user
      $c->auth->public($patron_id);
      ...

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
(cherry picked from commit 8a1c0af3e4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2025-02-24 14:19:22 +01:00
..
Acquisitions Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Auth Bug 36937: Remove warning from unit tests 2024-07-19 09:33:48 +02:00
Biblios Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
CashRegisters Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Clubs Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Config/SMTP Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
ERM Bug 38177: Do not use stash to retrieve parameters 2024-12-13 15:56:59 +01:00
OAuth Bug 34271: Remove a few Logger statements from REST API 2023-10-18 10:26:03 -03:00
Patrons Bug 28907: REST - Remove allow-owner from public patron hold cancellation 2025-02-24 14:19:22 +01:00
Preservation Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
AdvancedEditorMacro.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
ArticleRequests.pm Bug 28907: REST - Remove allow-owner from public article requests cancel route 2025-02-24 14:19:22 +01:00
Auth.pm Bug 28907: REST - Drop support for allow-owner functionality 2025-02-24 14:19:22 +01:00
AuthorisedValueCategories.pm Bug 34920: Return sorted av_cats to be able to test 2024-12-02 11:21:04 +01:00
AuthorisedValues.pm Bug 33556: Avoid relying on $c->validation 2023-07-21 17:14:37 -03:00
Authorities.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
BackgroundJobs.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Biblios.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Bookings.pm Bug 36100: (QA follow-up) Move 400 to 409 2024-03-11 11:00:23 +01:00
Checkouts.pm Bug 28907: REST - Remove allow-owner from public checkout availability route 2025-02-24 14:19:22 +01:00
CirculationRules.pm Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
Cities.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
ERM.pm Bug 33606: (QA follow-up) Cosmetic changes 2023-07-06 12:24:15 -03:00
Holds.pm Bug 35353: Add REST API endpoint to retrieve old holds 2024-05-24 10:07:38 +02:00
Illbackends.pm Bug 33556: Avoid relying on $c->validation 2023-07-21 17:14:37 -03:00
IllbatchStatuses.pm Bug 30719: (QA follow-up) Rename illbatchstatuses 2023-10-17 14:45:22 -03:00
Illbatches.pm Bug 30719: (QA follow-up) Pick better column names and cleanup 2023-10-17 14:45:23 -03:00
Illrequests.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
ImportBatchProfiles.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
ImportRecordMatches.pm Bug 33556: Avoid relying on $c->validation 2023-07-21 17:14:37 -03:00
ItemTypes.pm Bug 34008: (QA follow-up) 'item_type_id' should be used 2023-11-01 17:23:15 -03:00
Items.pm Bug 35963: Fix bundled items table ordering and filtering 2024-03-11 10:42:34 +01:00
Libraries.pm Bug 36482: Make embedding work for GET /libraries/:library_id 2024-05-24 10:15:28 +02:00
OAuth.pm Bug 33556: Avoid relying on $c->validation 2023-07-21 17:14:37 -03:00
Patrons.pm Bug 28907: REST - Remove allow-owner from public guarantors can see charges and checkouts 2025-02-24 14:19:22 +01:00
Preservation.pm Bug 30708: Tidy perl files 2023-10-18 15:42:04 -03:00
Quotes.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
ReturnClaims.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
SearchFilter.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Stage.pm Bug 33556: Avoid relying on $c->validation 2023-07-21 17:14:37 -03:00
Static.pm Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
Suggestions.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
Tickets.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
TransferLimits.pm Bug 36483: Make API controllers use $c->objects->to_api 2024-05-23 14:47:41 +02:00
TwoFactorAuth.pm Bug 30843: Add mfa_range configuration option for TOTP 2023-09-25 10:53:51 -03:00