sunspot heroku websolr authorization

298 Views Asked by At

We are using sunspot-rails to connect to websolr on Heroku. Websolr provides an authorization feature to protect read and update calls. This authorization feature requires three additional http headers to be present in every call to SOLR. I am trying to find out a way to add these http headers to every call going from sunspot. The following article shows how to do it for rsolr but not sunspot - https://github.com/onemorecloud/websolr-demo-advanced-auth. The official heroku doc at https://devcenter.heroku.com/articles/websolr has very little info about authorization. Is there a way to alter http headers through sunspot?

2

There are 2 best solutions below

1
On

You can customize the connection class used in the Sunspot session. You have see an example in this gist: https://gist.github.com/nz/6243059

0
On

I had to adapt @polmiro's gist a little bit to make it work: https://gist.github.com/alfonsocora/e1f979621bbfe98e10dc