Bugzilla – Attachment 105587 Details for
Bug 24003
REST API should set C4::Context->userenv
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24003: Make the API set userenv on authentication
Bug-24003-Make-the-API-set-userenv-on-authenticati.patch (text/plain), 2.01 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-06-05 12:49:40 UTC
(
hide
)
Description:
Bug 24003: Make the API set userenv on authentication
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-06-05 12:49:40 UTC
Size:
2.01 KB
patch
obsolete
>From 773d8bdf134f91fa54a467c48dd5b3dcbc6def05 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 5 Jun 2020 09:16:16 -0300 >Subject: [PATCH] Bug 24003: Make the API set userenv on authentication > >This patch makes the authentication step stash the user that got >authenticated so code outside the Mojo part of Koha can use it (i.e. >through the use of C4::Context->userenv). > >To test: >1. Apply the regression tests >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t \ > t/db_dependent/api/v1/auth_basic.t >=> FAIL: Tests fail! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Auth.pm | 7 +++++++ > 1 file changed, 7 insertions(+) > >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index a4bb7ae2331..b0966868b9f 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -154,6 +154,7 @@ sub authenticate_api_request { > my $spec = $c->openapi->spec || $c->match->endpoint->pattern->defaults->{'openapi.op_spec'}; > > $c->stash_embed({ spec => $spec }); >+ my $cookie_auth = 0; > > my $authorization = $spec->{'x-koha-authorization'}; > >@@ -222,6 +223,7 @@ sub authenticate_api_request { > $user = Koha::Patrons->find( $session->param('number') ) > unless $session->param('sessiontype') > and $session->param('sessiontype') eq 'anon'; >+ $cookie_auth = 1; > } > elsif ($status eq "maintenance") { > Koha::Exceptions::UnderMaintenance->throw( >@@ -247,6 +249,11 @@ sub authenticate_api_request { > > $c->stash('koha.user' => $user); > >+ if ( $user and !$cookie_auth ) { # cookie-auth sets this and more, don't mess with that >+ C4::Context->_new_userenv( $user->borrowernumber ); >+ C4::Context->set_userenv( $user->borrowernumber ); >+ } >+ > if ( !$authorization and > ( $params->{is_public} and > ( C4::Context->preference('RESTPublicAnonymousRequests') or >-- >2.27.0
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 24003
:
95228
|
95230
|
105579
|
105580
|
105581
|
105586
|
105587
|
105588
|
105633
|
105634
|
105635
|
105666
|
105844
|
105845
|
105846
|
105847
|
106087
|
106088
|
106089
|
106090