Bugzilla – Attachment 65088 Details for
Bug 18950
Elasticsearch - Add password access for admin functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18950 - Elasticsearch - Add password access for admin functions
Bug-18950---Elasticsearch---Add-password-access-fo.patch (text/plain), 6.28 KB, created by
Nick Clemens (kidclamp)
on 2017-07-18 12:11:32 UTC
(
hide
)
Description:
Bug 18950 - Elasticsearch - Add password access for admin functions
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-07-18 12:11:32 UTC
Size:
6.28 KB
patch
obsolete
>From aedd09d6463cce18ef25b2b4c1f61aef3e95a659 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 18 Jul 2017 12:05:07 +0000 >Subject: [PATCH] Bug 18950 - Elasticsearch - Add password access for admin > functions > >To test: >1 - Load 'Search engine configuration' from admin page >http://localhost:8081/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl >2 - Verify this works as before the patch >3 - Add <elasticsearch_admin_password> to koha-conf.xml >4 - Reload search config page, note additional option to reset mappings >5 - Attempt reset with bad password >6 - Attempt reset with correct password > >Note: the action is a drop down as reindexing will be added, however, > code needs some refactoring before this option can be implemented >--- > admin/searchengine/elasticsearch/mappings.pl | 21 +++++++++++++++------ > debian/scripts/koha-create | 3 +++ > debian/templates/koha-conf-site.xml.in | 4 ++++ > .../admin/searchengine/elasticsearch/mappings.tt | 21 ++++++++++++++++++++- > 4 files changed, 42 insertions(+), 7 deletions(-) > >diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl >index 7d63002..567451e 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -37,6 +37,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > > my $index = $input->param('index') || 'biblios'; > my $op = $input->param('op') || 'list'; >+my $action = $input->param('action') || ''; > my @messages; > > my $database = Koha::Database->new(); >@@ -97,12 +98,19 @@ if ( $op eq 'edit' ) { > $schema->storage->txn_commit; > } > } >-elsif( $op eq 'reset' ) { >- # TODO Move this feature to the interface >- my $sure = $input->param('i_know_what_i_am_doing'); >- if ( $sure ) { >- Koha::SearchMarcMaps->search->delete; >- Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; >+elsif( $op eq 'admin') { >+ if( $input->param('admin_password') eq C4::Context->config('elasticsearch_admin_password') ){ >+ if ( $action eq 'reset' ) { >+ Koha::SearchMarcMaps->search->delete; >+ Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; >+ $template->param( mappings_reset = 1 ); >+ } >+ elsif ( $action eq 'reindex' ) { >+ #TODO reindex needs some refactorig to allow this option >+ } >+ } >+ else { >+ $template->param( admin_badpassword => 1 ); > } > } > >@@ -139,6 +147,7 @@ $template->param( > indexes => \@indexes, > all_search_fields => \@all_search_fields, > messages => \@messages, >+ show_admin_options => C4::Context->config('elasticsearch_admin_password') ? 1 : 0, > ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create >index ba4f043..0b927be 100755 >--- a/debian/scripts/koha-create >+++ b/debian/scripts/koha-create >@@ -106,6 +106,7 @@ generate_config_file() { > -e "s/__START_AUTHORITIES_RETRIEVAL_INFO__/`echo $START_AUTHORITIES_RETRIEVAL_INFO`/g" \ > -e "s/__END_AUTHORITIES_RETRIEVAL_INFO__/`echo $END_AUTHORITIES_RETRIEVAL_INFO`/g" \ > -e "s/__API_SECRET__/$API_SECRET/g" \ >+ -e "s/__ES_ADMIN_PASSWORD__/$ES_ADMIN_PASSWORD/g" \ > -e "s/__DB_NAME__/$mysqldb/g" \ > -e "s/__DB_HOST__/$mysqlhost/g" \ > -e "s/__DB_USER__/$mysqluser/g" \ >@@ -406,6 +407,8 @@ UPLOAD_DIR="uploads" > UPLOAD_PATH="" > # Generate a randomizaed API secret > API_SECRET="$(pwgen -s 64 1)" >+# Generate a randomizaed ES Admin Password secret >+ES_ADMIN_PASSWORD="$(pwgen -s 16 1)" > # SRU server variables > ENABLE_SRU="no" > SRU_SERVER_PORT="" >diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in >index 8e8204f..e990b33 100644 >--- a/debian/templates/koha-conf-site.xml.in >+++ b/debian/templates/koha-conf-site.xml.in >@@ -326,6 +326,10 @@ __END_SRU_PUBLICSERVER__ > <server>localhost:9200</server> > <index_name>koha___KOHASITE__</index_name> > </elasticsearch> >+ <!-- Uncomment the following line to allow access to reindexing tools via Search >+ Configuration page in staff interface >+ <elasticsearch_admin_password>__ES_ADMIN_PASSWORD__</elasticsearch_admin_password> >+ --> > > </config> > </yazgfs> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >index 25535d9..45ee750 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >@@ -1,3 +1,4 @@ >+[% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Elastic Search mappings</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -88,7 +89,25 @@ a.add, a.delete { > > <h1>Search engine configuration</h1> > <div class="warning"> >- Warning: Any modification in these configurations will need a total reindexation to be fully taken into account ! >+ Warning: Any modification in these configurations will need a total reindexation to be fully taken into account ! <br/> >+ [% IF (show_admin_options) %] >+ [% IF (admin_badpassword) %]<p>The password you entered was incorrect!</p>[% END %] >+ [% IF (reindex_launched) %]<p>A rebuild has been started<p/> >+ [% ELSIF (mappings_reset) %]<p>Mappings have been reset<p/> >+ [% ELSE %] >+ <form method="post"> >+ <label for="admin_password">Enter the Elasticsearch admin password and select action</labe;> >+ <input type="text" name="admin_password" value="" id="admin_password"/> >+ <input type="hidden" name="op" value="admin" /> >+ <select name="action"> >+ [%# <option value="reindex">Launch reindex</option> Index needs refactoring to allow this option %] >+ <option value="reset">Reset mappings</option> >+ </select> >+ <input type="submit" value="Submit" /> >+ </form> >+ [% END %] >+ [% END %] >+ > </div> > [% IF errors %] > <div class="error"> >-- >2.1.4
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 18950
:
65088
|
65160