Bugzilla – Attachment 159234 Details for
Bug 34999
REST API: Public routes should respect OPACMaintenance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled
Bug-34999-Throw-exception-for-public-routes-if-OPA.patch (text/plain), 2.09 KB, created by
Marcel de Rooy
on 2023-11-24 10:57:12 UTC
(
hide
)
Description:
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-11-24 10:57:12 UTC
Size:
2.09 KB
patch
obsolete
>From 6394f7fb8952e17398b5921fa25064674269d8b7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 24 Nov 2023 10:50:54 +0000 >Subject: [PATCH] Bug 34999: Throw exception for public routes if > OPACMaintenance is enabled >Content-Type: text/plain; charset=utf-8 > >Test plan: >[1] Try public endpoint like /api/v1/public/biblios/X/items. > * Replace X by an existing biblionumber. > You should receive a 200. >[2] Enable OPACMaintenance. Set to Show. >[3] Try same endpoint. You should get a 503 with a json error. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/REST/V1/Auth.pm | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index b04fcaeb62..4e59ba4d4a 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -74,11 +74,12 @@ sub under { > $is_plugin = 1; > } > >- if ( $is_public >- and !C4::Context->preference('RESTPublicAPI') ) >- { >+ if ( $is_public ) { >+ Koha::Exceptions::UnderMaintenance->throw('Under maintenance') >+ if C4::Context->preference('OPACMaintenance'); > Koha::Exceptions::Authorization->throw( >- "Configuration prevents the usage of this endpoint by unprivileged users"); >+ "Configuration prevents the usage of this endpoint by unprivileged users") >+ if !C4::Context->preference('RESTPublicAPI'); > } > > if ( $c->req->url->to_abs->path =~ m#^/api/v1/oauth/# || $c->req->url->to_abs->path =~ m#^/api/v1/public/oauth/#) { >@@ -100,7 +101,7 @@ sub under { > ); > } > if ($_->isa('Koha::Exceptions::UnderMaintenance')) { >- return $c->render(status => 503, json => { error => $_->error }); >+ return $c->render(status => 503, json => { error => $_->message }); > } > elsif ($_->isa('Koha::Exceptions::Authentication::SessionExpired')) { > return $c->render(status => 401, json => { error => $_->error }); >-- >2.30.2
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 34999
:
159234
|
159235
|
160828
|
160829
|
160840
|
160841
|
160973
|
160974