Bugzilla – Attachment 74491 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: Move value => client_id + secret
Bug-20568-Move-value--clientid--secret.patch (text/plain), 12.40 KB, created by
Julian Maurice
on 2018-04-18 18:13:25 UTC
(
hide
)
Description:
Bug 20568: Move value => client_id + secret
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2018-04-18 18:13:25 UTC
Size:
12.40 KB
patch
obsolete
>From 0470510ba2e5994bf1d982b39ac6ba5f8b0be16f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 16 Apr 2018 16:04:26 -0300 >Subject: [PATCH] Bug 20568: Move value => client_id + secret > >This patch addresses the request from Julian that api keys are expected >to be client id/secret pairs. > >It does so by >- Adding 'client_id' and 'secret' columns >- Removing 'value' > >Tests got adjusted and so controller scripts and templates. >Both libs and tests changes have been squashed. This ones remain in >order to keep Owen's attribution on the template changes and avoid >rebase conflicts. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > .../intranet-tmpl/prog/en/includes/members-toolbar.inc | 2 +- > .../intranet-tmpl/prog/en/modules/members/apikeys.tt | 16 +++++++++------- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt | 12 +++++++----- > members/apikeys.pl | 12 ++++++------ > opac/opac-apikeys.pl | 13 ++++++------- > 5 files changed, 29 insertions(+), 26 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >index 280368bcb5..0c731b5a00 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >@@ -61,7 +61,7 @@ > [% END %] > > [% IF CAN_user_borrowers_edit_borrowers %] >- <li><a id="apikeys" href="/cgi-bin/koha/members/apikeys.pl?patron_id=[% borrowernumber %]">Manage API keys</a></li> >+ <li><a id="apikeys" href="/cgi-bin/koha/members/apikeys.pl?patron_id=[% patron.borrowernumber %]">Manage API keys</a></li> > [% ELSE %] > <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to manage API keys" id="apikeys" href="#">Manage API keys</a></li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt >index e710efdd2c..93ef624a51 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt >@@ -27,7 +27,7 @@ > <input type="hidden" name="patron_id" value="[% patron.id %]" /> > <input type="hidden" name="op" value="generate" /> > <fieldset class="brief"> >- <legend>Generate new key</legend> >+ <legend>Generate new client id/secret pair</legend> > <ol> > <li> > <label for="description">Description: </label> >@@ -42,13 +42,14 @@ > <div id="keys"> > [% IF api_keys && api_keys.size > 0 %] > <p> >- <button class="btn btn-default btn-xs toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new key</button> >+ <button class="btn btn-default btn-xs toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new client id/key pair</button> > </p> > <table> > <thead> > <tr> > <th>Description</th> >- <th>Key</th> >+ <th>Client ID</th> >+ <th>Secret</th> > <th>Active</th> > <th>Actions</th> > </tr> >@@ -57,18 +58,19 @@ > [% FOREACH key IN api_keys %] > <tr> > <td>[% key.description %]</td> >- <td>[% key.value %]</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/members/apikeys.pl" method="post"> > <input type="hidden" name="patron_id" value="[% patron.id %]" /> >- <input type="hidden" name="key" value="[% key.value %]" /> >+ <input type="hidden" name="key" value="[% key.id %]" /> > <input type="hidden" name="op" value="delete" /> > <button class="btn btn-default btn-xs delete" type="submit"><i class="fa fa-trash"></i> Delete</button> > </form> > <form action="/cgi-bin/koha/members/apikeys.pl" method="post"> > <input type="hidden" name="patron_id" value="[% patron.id %]" /> >- <input type="hidden" name="key" value="[% key.value %]" /> >+ <input type="hidden" name="key" value="[% key.id %]" /> > [% IF key.active %] > <input type="hidden" name="op" value="revoke" /> > <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button> >@@ -83,7 +85,7 @@ > </tbody> > </table> > [% ELSE %] >- <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new key</div> >+ <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new client id/secret pair</div> > [% END %] > </div> > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt >index 7feecdcda5..7aaddf41bd 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt >@@ -33,7 +33,7 @@ > </p> > <form id="add-api-key" action="/cgi-bin/koha/opac-apikeys.pl" method="post"> > <fieldset> >- <legend>Generate new key</legend> >+ <legend>Generate new client id/secret pair</legend> > <input type="hidden" name="patron_id" value="[% patron.id %]" /> > <input type="hidden" name="op" value="generate" /> > <label for="description">Description: </label> >@@ -48,7 +48,8 @@ > <thead> > <tr> > <th>Description</th> >- <th>Key</th> >+ <th>Client ID</th> >+ <th>Secret</th> > <th>Active</th> > <th>Actions</th> > </tr> >@@ -57,16 +58,17 @@ > [% FOREACH key IN api_keys %] > <tr> > <td>[% key.description %]</td> >- <td>[% key.value %]</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.value %]" /> >+ <input type="hidden" name="key" value="[% key.id %]" /> > <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.value %]" /> >+ <input type="hidden" name="key" value="[% key.id %]" /> > [% 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> >diff --git a/members/apikeys.pl b/members/apikeys.pl >index 183483bbbb..975ca86e5b 100755 >--- a/members/apikeys.pl >+++ b/members/apikeys.pl >@@ -67,8 +67,8 @@ if ($op) { > } > > if ( $op eq 'delete' ) { >- my $api_key = $cgi->param('key'); >- my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key }); >+ my $api_key_id = $cgi->param('key'); >+ my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id }); > if ($key) { > $key->delete; > } >@@ -77,8 +77,8 @@ if ($op) { > } > > if ( $op eq 'revoke' ) { >- my $api_key = $cgi->param('key'); >- my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key }); >+ my $api_key_id = $cgi->param('key'); >+ my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id }); > if ($key) { > $key->active(0); > $key->store; >@@ -88,8 +88,8 @@ if ($op) { > } > > if ( $op eq 'activate' ) { >- my $api_key = $cgi->param('key'); >- my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key }); >+ my $api_key_id = $cgi->param('key'); >+ my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id }); > if ($key) { > $key->active(1); > $key->store; >diff --git a/opac/opac-apikeys.pl b/opac/opac-apikeys.pl >index 7a776f3063..66167e8d38 100755 >--- a/opac/opac-apikeys.pl >+++ b/opac/opac-apikeys.pl >@@ -47,7 +47,6 @@ if ( not defined $patron > exit; > } > >- > my $op = $cgi->param('op'); > > if ($op) { >@@ -63,8 +62,8 @@ if ($op) { > } > > if ($op eq 'delete') { >- my $key = $cgi->param('key'); >- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key}); >+ my $key_id = $cgi->param('key'); >+ my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id }); > if ($api_key) { > $api_key->delete; > } >@@ -73,8 +72,8 @@ if ($op) { > } > > if ($op eq 'revoke') { >- my $key = $cgi->param('key'); >- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key }); >+ my $key_id = $cgi->param('key'); >+ my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id }); > if ($api_key) { > $api_key->active(0); > $api_key->store; >@@ -84,8 +83,8 @@ if ($op) { > } > > if ($op eq 'activate') { >- my $key = $cgi->param('key'); >- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key }); >+ my $key_id = $cgi->param('key'); >+ my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id }); > if ($api_key) { > $api_key->active(1); > $api_key->store; >-- >2.14.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 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