Koha-clms/Koha/REST/V1
Lari Taskula b75bf9a84a
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: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-06 13:54:34 +01:00
..
Acquisitions Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Auth Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Biblios Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
CashRegisters Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Clubs Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Config/SMTP Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ERM Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ILL Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
OAuth Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Patrons Bug 28907: REST - Remove allow-owner from public patron hold cancellation 2025-03-06 13:54:32 +01:00
Preservation Bug 37686: Fix render_resource_not_found() and render_resource_deleted() misses 2024-08-29 18:16:19 +02:00
StockRotation Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
AdvancedEditorMacro.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ArticleRequests.pm Bug 28907: REST - Remove allow-owner from public article requests cancel route 2025-03-06 13:54:33 +01:00
Auth.pm Bug 28907: REST - Drop support for allow-owner functionality 2025-03-06 13:54:34 +01:00
AuthorisedValueCategories.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
AuthorisedValues.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Authorities.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
BackgroundJobs.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Biblios.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Bookings.pm Bug 38175: (QA follow-up) DRY out PATCH handling 2024-10-24 18:27:24 +02:00
Checkouts.pm Bug 28907: REST - Remove allow-owner from public checkout availability route 2025-03-06 13:54:33 +01:00
CirculationRules.pm Bug 37256: Add 'PUT' for circulation rule sets 2025-02-18 10:55:32 +01:00
Cities.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
DeletedBiblios.pm Bug 37791: Fix 'Biblio not found' messages on the API 2024-10-11 12:21:29 +02:00
ERM.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ExtendedAttributeTypes.pm Bug 37577: Add additional fields for ERM packages 2024-11-08 16:09:19 +01:00
Holds.pm Bug 38253: Add lowest priority REST API endpoint for holds 2025-02-26 13:16:31 +01:00
ImportBatchProfiles.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ImportRecordMatches.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01: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 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Libraries.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Lists.pm Bug 28965: (QA follow-up) Fix misc qa issues 2024-11-08 16:09:22 +01:00
OAuth.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Patrons.pm Bug 28907: REST - Remove allow-owner from public guarantors can see charges and checkouts 2025-03-06 13:54:31 +01:00
Preservation.pm Bug 30708: Tidy perl files 2023-10-18 15:42:04 -03:00
Quotes.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
RecordSources.pm Bug 37513: Handle Koha::Exceptions::Object::FKConstraintDeletio in controller 2024-08-27 12:14:24 +02:00
ReturnClaims.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
SearchFilter.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Static.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Suggestions.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Tickets.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
TransferLimits.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
TwoFactorAuth.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00