Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-57161

Solr plugin for Global Search does not set Basic Authorization header correctly




      The Solr plugin for Global Search, when configured to use Basic Authorization to connect to the Solr server, does not appear to correctly set the basic authorization headers. Therefore, authentication fails and the Solr server cannot be configured.

      To reproduce this, a Solr server should be configured such that it can be accessed by Moodle behind a reverse proxy server that requires HTTP Basic Authentication. The authentication credentials are then entered in the Solr Connection settings page.

      Instead of seeing the message inviting us to set up the database schema on the Manage global search page, we see the misleading error message:

      Error creating the Solr schema: Field "itemid" already exists in Solr schema. You probably forgot to run this script before indexing data and fields were autocreated by Solr. Please delete the current index, create a new one and run setup_schema.php again before indexing data in Solr.

      under the 3. Setup search engine stage.

      The call to filelib's \curl->setHeader method on line 1247 of search/engine/solr/classes/engine.php uses two separate arguments to set up the HTTP header, but the method only accepts one. https://github.com/moodle/moodle/blob/master/search/engine/solr/classes/engine.php#L1227

      It appears to us that:

      $this->curl->setHeader('Authorization', 'Basic ' . base64_encode($authorization));

      should therefore be:

      $this->curl->setHeader('Authorization: Basic ' . base64_encode($authorization));

      Making this change on line 1247 of search/engine/solr/classes/engine.php, in our testing, allows the connection to succeed, as the header is passed correctly through curl to the Solr reverse proxy server.




            Unassigned Unassigned
            TestValleySchool Test Valley School
            Simey Lameze Simey Lameze
            Andrew Lyons Andrew Lyons
            Rajesh Taneja Rajesh Taneja
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            0 Vote for this issue
            6 Start watching this issue