Authentication username and password are not interpolated
lucabelluccini opened this issue · 0 comments
lucabelluccini commented
Logstash 7.6.2
Plugin version logstash-filter-http (1.0.2)
Summary
The http
filter is not interpolating the variables for the parameters username
/ password
.
How to reproduce
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
}
}
Expected
The header should contain Basic bXl1c2VybmFtZTpteXBhc3N3b3Jk
Output
The header contains Basic JXtbdXNlcm5hbWVdfTole1twYXNzd29yZF19
(represents %{[username]}:%{[password]}
).
Workaround
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