Bugzilla – Attachment 176708 Details for
Bug 28907
Potential unauthorized access in public REST routes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28907: Add REST exceptions for public routes auth
Bug-28907-Add-REST-exceptions-for-public-routes-au.patch (text/plain), 2.39 KB, created by
Marcel de Rooy
on 2025-01-17 09:44:49 UTC
(
hide
)
Description:
Bug 28907: Add REST exceptions for public routes auth
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-01-17 09:44:49 UTC
Size:
2.39 KB
patch
obsolete
>From 1bd75909bd8c52e43c257bfbaa9097e2d4898340 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Wed, 18 Sep 2024 10:21:47 +0000 >Subject: [PATCH] Bug 28907: Add REST exceptions for public routes auth >Content-Type: text/plain; charset=utf-8 > >To test: >1. perl -c Koha/REST/Plugin/Exceptions.pm >2. perl -c Koha/Exceptions/REST.pm > >More tests coming in following patches. > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Exceptions/REST.pm | 6 ++++++ > Koha/REST/Plugin/Exceptions.pm | 17 +++++++++++++++++ > 2 files changed, 23 insertions(+) > >diff --git a/Koha/Exceptions/REST.pm b/Koha/Exceptions/REST.pm >index bbcd0fed6b..f0150503c5 100644 >--- a/Koha/Exceptions/REST.pm >+++ b/Koha/Exceptions/REST.pm >@@ -8,6 +8,12 @@ use Exception::Class ( > 'Koha::Exceptions::REST' => { > isa => 'Koha::Exception', > }, >+ 'Koha::Exceptions::REST::Public::Authentication::Required' => { >+ description => "This public route requires authentication", >+ }, >+ 'Koha::Exceptions::REST::Public::Unauthorized' => { >+ description => "Unprivileged user cannot access another user's resources", >+ }, > 'Koha::Exceptions::REST::Query::InvalidOperator' => { > description => "Invalid operator found in query", > fields => ['operator'] >diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm >index 5107af103d..55c9cfc2c6 100644 >--- a/Koha/REST/Plugin/Exceptions.pm >+++ b/Koha/REST/Plugin/Exceptions.pm >@@ -68,6 +68,23 @@ sub register { > } > ); > } >+ elsif ( blessed $exception >+ && ref($exception) eq 'Koha::Exceptions::REST::Public::Authentication::Required' ) >+ { >+ return $c->render( >+ status => 401, >+ json => { >+ error => $exception->error, >+ } >+ ); >+ } elsif ( blessed $exception && ref($exception) eq 'Koha::Exceptions::REST::Public::Unauthorized' ) { >+ return $c->render( >+ status => 403, >+ json => { >+ error => $exception->error, >+ } >+ ); >+ } > > if ( blessed $exception ) { > $type = "(" . ref($exception) . ")"; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28907
:
171666
|
171667
|
171668
|
171669
|
171670
|
171671
|
171672
|
171673
|
171674
|
172434
|
172435
|
172436
|
172437
|
172438
|
172439
|
172440
|
172441
|
172442
|
174662
|
174663
|
174664
|
174665
|
174666
|
174667
|
174668
|
174669
|
174670
| 176708 |
176709
|
176710
|
176711
|
176712
|
176713
|
176714
|
176715
|
176716
|
177679
|
177680
|
177681
|
177682
|
177683
|
177684
|
177685
|
177686
|
177687
|
179000