Bug 36134

Summary: Elasticsearch authentication using userinfo parameter crashes about.pl
Product: Koha Reporter: Lari Taskula <lari.taskula>
Component: AboutAssignee: Lari Taskula <lari.taskula>
Status: Pushed to oldstable --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: aleisha, dcook, fridolin.somers, julian.maurice, lucas
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.04,23.05.10
Circulation function:
Bug Depends on: 33563    
Bug Blocks:    
Attachments: Bug 36134: Read complete Elasticsearch configuration in about.pl
Bug 36134: Read complete Elasticsearch configuration in about.pl
Bug 36134: Read complete Elasticsearch configuration in about.pl

Description Lari Taskula 2024-02-20 01:41:15 UTC
Following Bug 33563, if you enable Elasticsearch authentication using "userinfo" parameter in koha-conf (David's method in comment 3 of Bug 33563), about.pl page breaks and gives an internal server error.
Comment 1 Lari Taskula 2024-02-20 01:57:51 UTC
Created attachment 162286 [details] [review]
Bug 36134: Read complete Elasticsearch configuration in about.pl

When enabling Elasticsearch authentication in Koha using userinfo
parameter of Search::Elasticsearch, about.pl breaks and gives an
internal server error.

This patch reads the complete Elasticsearch configuration for
about.pl including userinfo causing about.pl to recover.

To test:
1. In Elasticsearch 7 settings, set "xpack.security.enabled: true"
2. Add <userinfo>elastic:password</userinfo> to KOHA_CONF elasticsearch
   settings
3. Restart plack and navigate to about.pl
4. Observe internal server error
5. Apply patch
6. Refresh about.pl
7. Observe it working again
Comment 2 Lari Taskula 2024-02-20 02:01:31 UTC Comment hidden (obsolete)
Comment 3 Lari Taskula 2024-02-20 02:05:31 UTC
Above patch should not change about.pl behavior for Kohas using Basic authentication within "server" setting or no authentication at all for Elasticsearch, but helps those using the "userinfo" setting.
Comment 4 David Cook 2024-02-20 03:39:02 UTC
The test plan needs some modifications for koha-testing-docker:

1. In the docker-compose.yml file, change xpack.security.enabled=false to xpack.security.enabled=true
2. In the docker-compose.yml file, add another environment variable for the "es" container like the following:
ELASTIC_PASSWORD=awesomepassword

You'll end up with a koha-conf.xml element like the following then:

<userinfo>elastic:awesomepassword</userinfo>
Comment 5 David Cook 2024-02-20 03:40:08 UTC
Good catch, Lari. Thanks for taking the time to do this.

QA tools look good too.
Comment 6 David Cook 2024-02-20 03:40:30 UTC
Created attachment 162287 [details] [review]
Bug 36134: Read complete Elasticsearch configuration in about.pl

When enabling Elasticsearch authentication in Koha using userinfo
parameter of Search::Elasticsearch, about.pl breaks and gives an
internal server error.

This patch reads the complete Elasticsearch configuration for
about.pl including userinfo causing about.pl to recover.

To test:
1. In Elasticsearch 7 settings, set "xpack.security.enabled: true"
2. Add <userinfo>elastic:password</userinfo> to KOHA_CONF elasticsearch
   settings
3. Restart plack and navigate to about.pl
4. Observe internal server error
5. Apply patch
6. Refresh about.pl
7. Observe it working again

Signed-off-by: David Cook <dcook@prosentient.com.au>
Comment 7 Julian Maurice 2024-02-23 09:17:56 UTC
Created attachment 162366 [details] [review]
Bug 36134: Read complete Elasticsearch configuration in about.pl

When enabling Elasticsearch authentication in Koha using userinfo
parameter of Search::Elasticsearch, about.pl breaks and gives an
internal server error.

This patch reads the complete Elasticsearch configuration for
about.pl including userinfo causing about.pl to recover.

To test:
1. In Elasticsearch 7 settings, set "xpack.security.enabled: true"
2. Add <userinfo>elastic:password</userinfo> to KOHA_CONF elasticsearch
   settings
3. Restart plack and navigate to about.pl
4. Observe internal server error
5. Apply patch
6. Refresh about.pl
7. Observe it working again

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 8 Katrin Fischer 2024-03-07 16:37:28 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 9 Fridolin Somers 2024-03-11 10:20:19 UTC
Pushed to 23.11.x for 23.11.04
Comment 10 Lucas Gass (lukeg) 2024-03-19 20:06:29 UTC
Backported to 23.05.x for upcoming 23.05.10