Bugzilla – Attachment 83684 Details for
Bug 21198
authenticate_api_request should stash the reason access is granted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21198: Make authenticate_api_request stash the reason access is granted
Bug-21198-Make-authenticateapirequest-stash-the-re.patch (text/plain), 1.71 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-01-07 13:30:25 UTC
(
hide
)
Description:
Bug 21198: Make authenticate_api_request stash the reason access is granted
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-01-07 13:30:25 UTC
Size:
1.71 KB
patch
obsolete
>From 876410de46c770c5aa001a629a020f29a282932f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 7 Jan 2019 10:24:59 -0300 >Subject: [PATCH] Bug 21198: Make authenticate_api_request stash the reason > access is granted > >This patch makes the authenticate_api_request method stash the reason >the request or has been granted access to the resource. > >Possible values are: >- permissions >- owner >- guarantor > >This will allow the controllers to avoid querying on their own for this >info. > >To test: >- Run: > $ kshell > k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t >=> SUCCESS: Tests pass! >- Sign off :-D >--- > Koha/REST/V1/Auth.pm | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index 0fc211f054..0bbbf0c337 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -213,10 +213,21 @@ sub authenticate_api_request { > > my $permissions = $authorization->{'permissions'}; > # Check if the user is authorized >- if ( haspermission($user->userid, $permissions) >- or allow_owner($c, $authorization, $user) >- or allow_guarantor($c, $authorization, $user) ) { >+ if ( haspermission($user->userid, $permissions) ) { >+ $c->stash( 'grant_reason', 'permissions' ); >+ } >+ else { >+ if ( allow_owner($c, $authorization, $user) ){ >+ $c->stash( 'grant_reason', 'owner' ); >+ } >+ else { >+ if ( allow_guarantor($c, $authorization, $user) ) { >+ $c->stash( 'grant_reason', 'guarantor' ); >+ } >+ } >+ } > >+ if ( $c->stash('grant_reason') ) { > validate_query_parameters( $c, $spec ); > > # Everything is ok >-- >2.20.1
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 21198
:
83683
| 83684