lib/fluent/plugin/in_sendgrid_event.rb in fluent-plugin-sendgrid-event-0.0.2 vs lib/fluent/plugin/in_sendgrid_event.rb in fluent-plugin-sendgrid-event-0.0.3

- old
+ new

@@ -8,10 +8,12 @@ config_param :host, :string, :default => "0.0.0.0" config_param :port, :integer, :default => 9191 config_param :ssl, :bool, :default => false config_param :certificate, :string, :default => nil config_param :private_key, :string, :default => nil + config_param :username, :string, :default => nil + config_param :password, :string, :default => nil config_param :request_uri, :string, :default => "/" unless method_defined?(:log) define_method("log") { $log } end @@ -55,9 +57,16 @@ listen[:SSLEnable] = @ssl listen[:SSLCertificate] = OpenSSL::X509::Certificate.new(open(@certificate).read) listen[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(open(@private_key).read) else log.error "in_sendgrid_event: couldn't find certificate: '#{@certificate}' or ssl key: '#{@private_key}'" + end + end + if @username && @password + listen[:RequestCallback] = lambda do |req, res| + WEBrick::HTTPAuth.basic_auth(req, res, "fluent-plugin-sendgrid-event") do |username, password| + username == @username && @password + end end end @server = WEBrick::HTTPServer.new(listen) @server.mount_proc(@request_uri) do |req, res|