Commit 5ffe9a18 by Tran Hoang Viet

VietTH: Add authenticate to solr admin

parent b04d8363
module RsolrAuthenticate
require 'rsolr/connection'
class RSolr::Connection
protected
def setup_raw_request_with_basic_auth request_context
raw_request = setup_raw_request_without_basic_auth(request_context)
raw_request.basic_auth(ENV['SOLR_USER'], ENV['SOLR_PWD'])
raw_request
end
alias_method :setup_raw_request_without_basic_auth, :setup_raw_request
alias_method :setup_raw_request, :setup_raw_request_with_basic_auth
end
end
\ No newline at end of file
module Solr extend ActiveSupport::Concern module Solr extend ActiveSupport::Concern
include RsolrAuthenticate
included do included do
after_save :push_data_to_solr after_save :push_data_to_solr
after_destroy :remove_from_solr after_destroy :remove_from_solr
...@@ -75,6 +78,7 @@ module Solr extend ActiveSupport::Concern ...@@ -75,6 +78,7 @@ module Solr extend ActiveSupport::Concern
end end
def rsolr def rsolr
@rsolr_service ||= RSolr.connect(url: Settings.solr_url) @rsolr_service ||= RSolr.connect(url: Settings.solr_url)
end end
......
...@@ -26,5 +26,9 @@ module VenShop ...@@ -26,5 +26,9 @@ module VenShop
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq
config.autoload_paths += Dir["#{config.root}/app/services/**/*.rb"] config.autoload_paths += Dir["#{config.root}/app/services/**/*.rb"]
console do
ActiveRecord::Base.logger = Rails.logger = Logger.new(STDOUT)
end
end end
end end
...@@ -9,3 +9,5 @@ S3_SECRET: WzHwCJowOJoZGQ9DbHWvzdVhYtpOrDpuynEiK4YL ...@@ -9,3 +9,5 @@ S3_SECRET: WzHwCJowOJoZGQ9DbHWvzdVhYtpOrDpuynEiK4YL
FB_APP_ID: 1629224294024346 FB_APP_ID: 1629224294024346
SOLR_URL: http://localhost:8080/solr/venshop SOLR_URL: http://localhost:8080/solr/venshop
SOLR_USER: admin
SOLR_PWD: 123456
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment