Skip to content

Commit

Permalink
Rewrite elasticsearch connection URL (elastic#3058)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkroh authored and ruflin committed Nov 23, 2016
1 parent edfb610 commit 38369fb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ func NewClient(
}
}

u, err := url.Parse(s.URL)
if err != nil {
return nil, fmt.Errorf("failed to parse elasticsearch URL: %v", err)
}
if u.User != nil {
s.Username = u.User.Username()
s.Password, _ = u.User.Password()
u.User = nil

// Re-write URL without credentials.
s.URL = u.String()
}

client := &Client{
Connection: Connection{
URL: s.URL,
Expand Down

0 comments on commit 38369fb

Please sign in to comment.