Open lucabelluccini opened 4 years ago
Logstash 7.6.2 Plugin version logstash-filter-http (1.0.2)
The http filter is not interpolating the variables for the parameters username / password.
http
username
password
input { exec { command => 'echo "myusername mypassword something else as message"' interval => 30 } } filter { grok { match => { "message" => "(?<username>.*?) (?<password>.*?) %{GREEDYDATA:message}" } overwrite => [ "message" ] } http { url => "https://postman-echo.com/post" verb => "POST" body_format => text body => "%{[message]}" headers => { "mytest" => "logstash" } user => "%{[username]}" password => "%{[password]}" } } output { stdout { codec => rubydebug } }
The header should contain Basic bXl1c2VybmFtZTpteXBhc3N3b3Jk
Basic bXl1c2VybmFtZTpteXBhc3N3b3Jk
The header contains Basic JXtbdXNlcm5hbWVdfTole1twYXNzd29yZF19 (represents %{[username]}:%{[password]}).
Basic JXtbdXNlcm5hbWVdfTole1twYXNzd29yZF19
%{[username]}:%{[password]}
ruby { init => "require 'base64'" code => "event.set('auth_header', 'Basic ' + Base64.strict_encode64(event.get('username')+':'+event.get('password')))" } http { url => "https://postman-echo.com/post" verb => "POST" body_format => text body => "%{[message]}" headers => { "authorization" => "%{[auth_header]}" "mytest" => "logstash" } remove_field => [ "auth_header"] }
From https://discuss.elastic.co/t/http-filter-plugin-authorization-as-parameter-values/232085/6
Logstash 7.6.2 Plugin version logstash-filter-http (1.0.2)
Summary
The
http
filter is not interpolating the variables for the parametersusername
/password
.How to reproduce
Expected
The header should contain
Basic bXl1c2VybmFtZTpteXBhc3N3b3Jk
Output
The header contains
Basic JXtbdXNlcm5hbWVdfTole1twYXNzd29yZF19
(represents%{[username]}:%{[password]}
).Workaround
From https://discuss.elastic.co/t/http-filter-plugin-authorization-as-parameter-values/232085/6