Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication username and password are not interpolated #24

Open
lucabelluccini opened this issue May 11, 2020 · 0 comments
Open

Authentication username and password are not interpolated #24

lucabelluccini opened this issue May 11, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@lucabelluccini
Copy link

lucabelluccini commented May 11, 2020

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

@kares kares added the enhancement New feature or request label May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants