Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sunspot heroku websolr authorization

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?

like image 407
anishdeena Avatar asked Oct 22 '22 07:10

anishdeena


2 Answers

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

like image 133
polmiro Avatar answered Oct 29 '22 14:10

polmiro


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

like image 43
alf Avatar answered Oct 29 '22 15:10

alf