Bugzilla – Attachment 74981 Details for
Bug 20568
Add API key management interface for patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20568: (QA follow-up) Remove api-key management from OPAC
Bug-20568-QA-follow-up-Remove-api-key-management-f.patch (text/plain), 14.30 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-05-02 14:13:12 UTC
(
hide
)
Description:
Bug 20568: (QA follow-up) Remove api-key management from OPAC
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-05-02 14:13:12 UTC
Size:
14.30 KB
patch
obsolete
>From 3f07b0886bc93cb19311527ddcb9294292a0ecde Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 2 May 2018 11:05:05 -0300 >Subject: [PATCH] Bug 20568: (QA follow-up) Remove api-key management from OPAC > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../atomicupdate/bug_20568_api_keys.perl | 7 -- > installer/data/mysql/sysprefs.sql | 1 - > .../admin/preferences/web_services.pref | 6 - > .../bootstrap/en/includes/usermenu.inc | 10 -- > .../bootstrap/en/modules/opac-apikeys.tt | 110 ---------------- > opac/opac-apikeys.pl | 119 ------------------ > 6 files changed, 253 deletions(-) > delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt > delete mode 100755 opac/opac-apikeys.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_20568_api_keys.perl b/installer/data/mysql/atomicupdate/bug_20568_api_keys.perl >index 21e1884702..0267f35991 100644 >--- a/installer/data/mysql/atomicupdate/bug_20568_api_keys.perl >+++ b/installer/data/mysql/atomicupdate/bug_20568_api_keys.perl >@@ -20,13 +20,6 @@ if(CheckVersion($DBversion)) { > }); > } > >- $dbh->do(q{ >- INSERT IGNORE INTO `systempreferences` >- (variable,value,explanation,options,type) >- VALUES >- ('AllowPatronsManageAPIKeysInOPAC', '0', 'If enabled, patrons can manage their own API keys in the OPAC', NULL, 'YesNo'); >- }); >- > print "Upgrade to $DBversion done (Bug 20568 - Add API key management interface for patrons)\n"; > SetVersion($DBversion); > } >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 2b0aad6c14..34e5cc4744 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -30,7 +30,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'), > ('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'), > ('AllowPatronToSetCheckoutsVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor', 'YesNo'), >-('AllowPatronsManageAPIKeysInOPAC', '0', NULL, 'If enabled, patrons can manage their own API keys in the OPAC', 'YesNo'), > ('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'), > ('AllowPurchaseSuggestionBranchChoice','0','1','Allow user to choose branch when making a purchase suggestion','YesNo'), > ('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >index 351104e5a6..82f7501e38 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >@@ -5,12 +5,6 @@ Web services: > - pref: "RESTdefaultPageSize" > class: integer > - "per page" >- - >- - pref: AllowPatronsManageAPIKeysInOPAC >- choices: >- yes: Allow >- no: "Don't allow" >- - "patrons to manage their own API keys in the OPAC." > OAI-PMH: > - > - pref: OAI-PMH >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc >index 3024121344..da5e1ec8a8 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc >@@ -124,16 +124,6 @@ > <a href="/cgi-bin/koha/opac-illrequests.pl">your interlibrary loan requests</a></li> > [% END %] > >- >- [% IF Koha.Preference('AllowPatronsManageAPIKeysInOPAC') %] >- [% IF apikeysview %] >- <li class="active"> >- [% ELSE %] >- <li> >- [% END %] >- <a href="/cgi-bin/koha/opac-apikeys.pl">your API keys</a> >- [% END %] >- </li> > </ul> > </div> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt >deleted file mode 100644 >index 7d958b74b7..0000000000 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt >+++ /dev/null >@@ -1,110 +0,0 @@ >-[% INCLUDE 'doc-head-open.inc' %] >-<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your API keys</title> >-[% INCLUDE 'doc-head-close.inc' %] >-[% BLOCK cssinclude %][% END %] >-</head> >-[% INCLUDE 'bodytag.inc' bodyid='opac-user' bodyclass='scrollto' %] >-[% INCLUDE 'masthead.inc' %] >- >-<div class="main"> >- <ul class="breadcrumb"> >- <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> >- <li> >- <a href="/cgi-bin/koha/opac-user.pl"> >- [% INCLUDE 'patron-title.inc' category_type=patron.category.category_type firstname=patron.firstname surname=patron.surname othernames=patron.othernames %] >- </a> >- <span class="divider">›</span> >- </li> >- <li><a href="/cgi-bin/koha/opac-apikeys.pl">Your API keys</a></li> >- </ul> >- >- <div class="container-fluid"> >- <div class="row-fluid"> >- <div class="span2"> >- <div id="navigation"> >- [% INCLUDE 'navigation.inc' IsPatronPage = 1 %] >- </div> >- </div> >- <div class="span10"> >- <div id="apikeys" class="maincontent"> >- <h1>Your API keys</h1> >- <p> >- <button id="show-api-form" style="display:none" class="btn btn-default btn-sm" type="button"><i class="fa fa-plus"></i> Generate new key</button> >- </p> >- <form id="add-api-key" action="/cgi-bin/koha/opac-apikeys.pl" method="post"> >- <fieldset> >- <legend>Generate new client id/secret pair</legend> >- <input type="hidden" name="patron_id" value="[% patron.id %]" /> >- <input type="hidden" name="csrf_token" value="[% csrf_token %]" /> >- <input type="hidden" name="op" value="generate" /> >- <label for="description">Description: </label> >- <input type="text" name="description" /> >- </fieldset> >- <fieldset class="action"> >- <button class="btn btn-default btn-sm" type="submit">Save</button> <a href="#" style="display:none" class="cancel cancel-api-key">Cancel</a> >- </fieldset> >- </form> >- [% IF api_keys && api_keys.size > 0 %] >- <table class="table table-bordered table-striped"> >- <thead> >- <tr> >- <th>Description</th> >- <th>Client ID</th> >- <th>Secret</th> >- <th>Active</th> >- <th>Actions</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH key IN api_keys %] >- <tr> >- <td>[% key.description %]</td> >- <td>[% key.client_id %]</td> >- <td>[% key.secret %]</td> >- <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td> >- <td> >- <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline"> >- <input type="hidden" name="key" value="[% key.id %]" /> >- <input type="hidden" name="csrf_token" value="[% csrf_token %]" /> >- <input type="hidden" name="op" value="delete" /> >- <button class="btn btn-link btn-xs delete-key" type="submit"><i class="fa fa-trash"></i> Delete</button> >- </form> >- <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline"> >- <input type="hidden" name="key" value="[% key.id %]" /> >- <input type="hidden" name="csrf_token" value="[% csrf_token %]" /> >- [% IF key.active %] >- <input type="hidden" name="op" value="revoke" /> >- <button class="btn btn-link btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button> >- [% ELSE %] >- <input type="hidden" name="op" value="activate" /> >- <button class="btn btn-link btn-xs" type="submit"><i class="fa fa-play"></i> Activate</button> >- [% END %] >- </form> >- </td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% ELSE %] >- <p>No keys defined for the current patron.</p> >- [% END %] >- </div> <!-- /#apikeys --> >- </div> <!-- /.span10 --> >- </div> <!-- /.row-fluid --> >- </div> <!-- /.container-fluid --> >-</div> <!-- /#main --> >- >-[% BLOCK jsinclude %] >- <script> >- $(document).ready(function(){ >- $("#add-api-key, #show-api-form, .cancel-api-key").toggle(); >- $("#show-api-form, .cancel-api-key").on("click", function(){ >- $("#add-api-key, #show-api-form").toggle(); >- }); >- $(".delete-key").on("click", function(){ >- return confirm(_("Are you sure you want to delete this key?")); >- }); >- }); >- </script> >-[% END %] >-[% INCLUDE 'opac-bottom.inc' %] >diff --git a/opac/opac-apikeys.pl b/opac/opac-apikeys.pl >deleted file mode 100755 >index 021c21b91b..0000000000 >--- a/opac/opac-apikeys.pl >+++ /dev/null >@@ -1,119 +0,0 @@ >-#!/usr/bin/env perl >- >-# This file is part of Koha. >-# >-# Copyright 2015 BibLibre >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >- >-use CGI; >- >-use C4::Auth; >-use C4::Output; >- >-use Koha::ApiKeys; >-use Koha::Patrons; >-use Koha::Token; >- >-my $cgi = new CGI; >- >-my ($template, $loggedinuser, $cookie) = get_template_and_user({ >- template_name => 'opac-apikeys.tt', >- query => $cgi, >- type => 'opac', >- authnotrequired => 0 >-}); >- >-my $patron_id = $loggedinuser; >-my $patron = Koha::Patrons->find( $patron_id ); >- >-if ( not defined $patron >- or !C4::Context->preference('AllowPatronsManageAPIKeysInOPAC') ) >-{ >- # patron_id invalid -> exit >- print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early >- exit; >-} >- >-my $op = $cgi->param('op') // ''; >- >-if ( $op eq 'generate' or >- $op eq 'delete' or >- $op eq 'revoke' or >- $op eq 'activate' ) { >- >- die "Wrong CSRF token" >- unless Koha::Token->new->check_csrf({ >- session_id => scalar $cgi->cookie('CGISESSID'), >- token => scalar $cgi->param('csrf_token'), >- }); >-} >- >-if ($op) { >- if ($op eq 'generate') { >- my $description = $cgi->param('description') // ''; >- my $apikey = Koha::ApiKey->new({ >- patron_id => $patron_id, >- description => $description >- }); >- $apikey->store; >- print $cgi->redirect('/cgi-bin/koha/opac-apikeys.pl'); >- exit; >- } >- >- if ($op eq 'delete') { >- my $key_id = $cgi->param('key'); >- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $key_id }); >- if ($api_key) { >- $api_key->delete; >- } >- print $cgi->redirect('/cgi-bin/koha/opac-apikeys.pl'); >- exit; >- } >- >- if ($op eq 'revoke') { >- my $key_id = $cgi->param('key'); >- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $key_id }); >- if ($api_key) { >- $api_key->active(0); >- $api_key->store; >- } >- print $cgi->redirect('/cgi-bin/koha/opac-apikeys.pl'); >- exit; >- } >- >- if ($op eq 'activate') { >- my $key_id = $cgi->param('key'); >- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $key_id }); >- if ($api_key) { >- $api_key->active(1); >- $api_key->store; >- } >- print $cgi->redirect('/cgi-bin/koha/opac-apikeys.pl'); >- exit; >- } >-} >- >-my @api_keys = Koha::ApiKeys->search({ patron_id => $patron_id }); >- >-$template->param( >- api_keys => \@api_keys, >- apikeysview => 1, >- csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $cgi->cookie('CGISESSID') }), >- patron => $patron >-); >- >-output_html_with_http_headers $cgi, $cookie, $template->output; >-- >2.17.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 20568
:
74179
|
74180
|
74229
|
74230
|
74231
|
74232
|
74233
|
74234
|
74235
|
74236
|
74248
|
74254
|
74255
|
74256
|
74257
|
74258
|
74259
|
74343
|
74344
|
74345
|
74346
|
74347
|
74348
|
74388
|
74389
|
74434
|
74454
|
74476
|
74477
|
74478
|
74479
|
74480
|
74481
|
74482
|
74486
|
74487
|
74488
|
74489
|
74490
|
74491
|
74492
|
74493
|
74494
|
74495
|
74496
|
74980
| 74981 |
75023
|
75186
|
75187
|
75188