Bugzilla – Attachment 52995 Details for
Bug 14868
REST API: Swagger2-driven permission checking
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14868: Rename 'x-koha-permission' to 'x-koha-authorization'
SIGNED-OFF-Bug-14868-Rename-x-koha-permission-to-x.patch (text/plain), 4.22 KB, created by
Johanna Räisä
on 2016-06-30 13:54:09 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14868: Rename 'x-koha-permission' to 'x-koha-authorization'
Filename:
MIME Type:
Creator:
Johanna Räisä
Created:
2016-06-30 13:54:09 UTC
Size:
4.22 KB
patch
obsolete
>From 90e622cfc611113dcc4e6f19c754854c7df58bde Mon Sep 17 00:00:00 2001 >From: Lari Taskula <larit@student.uef.fi> >Date: Thu, 30 Jun 2016 14:36:32 +0300 >Subject: [PATCH] [SIGNED-OFF] Bug 14868: Rename 'x-koha-permission' to > 'x-koha-authorization' >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Since we need to be able to define other authorization options than simply Koha >permissions, for example "allow-owner", we should rename x-koha-permission into >x-koha-authorization to better describe the object. > >This patch simply renames all occurences of x-koha-permission into >x-koha-authorization. > >The new specification for authorization: >"/patrons/{borrowernumber}": { > .. > "x-koha-authorization": { > "allow-owner": "1", > "pemissions": { > "borrowers": "1" > } > } >} > >Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> > >My name is Olli-Antti Kivilahti and I approve this commit. >We have been using the Swagger2.0-driven REST API on Mojolicious for 1 year now >in production and I am certain we have a pretty good idea on how to work with >the limitations of Swagger2.0 >We participated in the development of the Mojolicious::Plugin::Swagger and know >it well. We have made an extension to the plugin to provide full CORS support >and have been building all our in-house features on the new REST API. > >Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com> > >My name is Johanna Räisä and I approve this commit. >We have been using Swagger2.0-driven REST API in production successfully. >--- > Koha/REST/V1.pm | 6 +++--- > api/v1/swagger/paths/holds.json | 8 ++++---- > api/v1/swagger/paths/patrons.json | 4 ++-- > 3 files changed, 9 insertions(+), 9 deletions(-) > >diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm >index 568cbd5..b8f4f0e 100644 >--- a/Koha/REST/V1.pm >+++ b/Koha/REST/V1.pm >@@ -104,11 +104,11 @@ sub authenticate_api_request { > ); > } > >- if ($action_spec->{'x-koha-permission'}) { >+ if ($action_spec->{'x-koha-authorization'}) { > if (_allowOwner($c, $action_spec, $user)) { > return $next->($c); > } >- my $permissions = $action_spec->{'x-koha-permission'}->{'permissions'}; >+ my $permissions = $action_spec->{'x-koha-authorization'}->{'permissions'}; > > if (C4::Auth::haspermission($user->userid, $permissions)) { > return $next->($c); >@@ -129,7 +129,7 @@ sub authenticate_api_request { > sub _allowOwner { > my ($c, $action_spec, $user) = @_; > >- my $allowOwner = $action_spec->{'x-koha-permission'}->{'allow-owner'}; >+ my $allowOwner = $action_spec->{'x-koha-authorization'}->{'allow-owner'}; > > return unless $allowOwner && $allowOwner == 1; > if ($c->param("borrowernumber")) { >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index 1371239..72602a6 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -22,7 +22,7 @@ > } > } > }, >- "x-koha-permission": { >+ "x-koha-authorization": { > "allow-owner": "1", > "permissions": { > "borrowers": "1" >@@ -99,7 +99,7 @@ > } > } > }, >- "x-koha-permission": { >+ "x-koha-authorization": { > "allow-owner": "1", > "permissions": { > "reserveforothers": "1" >@@ -161,7 +161,7 @@ > } > } > }, >- "x-koha-permission": { >+ "x-koha-authorization": { > "permissions": { > "reserveforothers": "1" > } >@@ -189,7 +189,7 @@ > } > } > }, >- "x-koha-permission": { >+ "x-koha-authorization": { > "permissions": { > "reserveforothers": "1" > } >diff --git a/api/v1/swagger/paths/patrons.json b/api/v1/swagger/paths/patrons.json >index 3db7fe6..6cfafe3 100644 >--- a/api/v1/swagger/paths/patrons.json >+++ b/api/v1/swagger/paths/patrons.json >@@ -23,7 +23,7 @@ > } > } > }, >- "x-koha-permission": { >+ "x-koha-authorization": { > "permissions": { > "borrowers": "1" > } >@@ -61,7 +61,7 @@ > } > } > }, >- "x-koha-permission": { >+ "x-koha-authorization": { > "allow-owner": "1", > "permissions": { > "borrowers": "1" >-- >1.9.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 14868
:
42761
|
52577
|
52578
|
52579
|
52592
|
52593
|
52594
|
52602
|
52603
|
52604
|
52963
|
52964
|
52965
|
52966
|
52967
|
52981
|
52992
|
52993
|
52994
|
52995
|
52996
|
54457
|
54458
|
54459
|
54631
|
54632
|
54633
|
54765
|
54766
|
54767
|
54770
|
54771
|
54894
|
54895
|
54896
|
54897
|
55084
|
55085
|
55086
|
55087
|
55088
|
55089
|
55099
|
55100
|
55101
|
55102
|
55103
|
55104
|
55105