-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add Central Management feature #8559
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8ecfa51
Beats enrollment subcommand (#7182)
exekias 229e900
Add API client to retrieve configurations from CM (#8155)
exekias 9876164
Add central management service (#8263)
exekias 268be1a
Register output for reloading (#8378)
exekias 5251fe1
Also send beat name when enrolling (#8380)
exekias d3573bc
Refactor how configs are stored (#8379)
exekias a951985
Use beat name var when registering confs (#8435)
exekias 7ac4f35
Allow user/passwd based enrollment (#8524)
exekias 4ef8108
Merge branch 'master' into feature-centralmgmt
a43e3f1
Add changelog
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"syscall" | ||
|
||
"github.com/pkg/errors" | ||
"golang.org/x/crypto/ssh/terminal" | ||
) | ||
|
||
type method func(m string) (string, error) | ||
|
||
var methods = map[string]method{ | ||
"stdin": stdin, | ||
"env": env, | ||
} | ||
|
||
// ReadPassword allows to read a password passed as a command line parameter. | ||
// It offers several ways to read the password so it is not directly passed as a plain text argument: | ||
// stdin - Will prompt the user to input the password | ||
// env:VAR_NAME - Will read the password from the given env variable | ||
// | ||
func ReadPassword(def string) (string, error) { | ||
if len(def) == 0 { | ||
return "", errors.New("empty password definition") | ||
} | ||
|
||
var method, params string | ||
parts := strings.SplitN(def, ":", 2) | ||
method = strings.ToLower(parts[0]) | ||
|
||
if len(parts) == 2 { | ||
params = parts[1] | ||
} | ||
|
||
m := methods[method] | ||
if m == nil { | ||
return "", errors.New("unknown password source, use stdin or env:VAR_NAME") | ||
} | ||
|
||
return m(params) | ||
} | ||
|
||
func stdin(p string) (string, error) { | ||
fmt.Print("Enter password: ") | ||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin)) | ||
if err != nil { | ||
return "", errors.Wrap(err, "reading password input") | ||
} | ||
return string(bytePassword), nil | ||
} | ||
|
||
func env(p string) (string, error) { | ||
if len(p) == 0 { | ||
return "", errors.New("env variable name is needed when using env: password method") | ||
} | ||
|
||
return os.Getenv(p), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package cli | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReadPassword(t *testing.T) { | ||
os.Setenv("FOO", "random") | ||
|
||
tests := []struct { | ||
name string | ||
input string | ||
password string | ||
error bool | ||
}{ | ||
{ | ||
name: "Test env variable", | ||
input: "env:FOO", | ||
password: "random", | ||
}, | ||
{ | ||
name: "Test unknown method", | ||
input: "foo:bar", | ||
error: true, | ||
}, | ||
{ | ||
name: "Test empty input", | ||
input: "", | ||
error: true, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
password, err := ReadPassword(test.input) | ||
assert.Equal(t, test.password, password) | ||
|
||
if test.error { | ||
assert.Error(t, err) | ||
} else { | ||
assert.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remind me in which case we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically when doing enrollment, Kibana will probably be using x-pack security, so you need user/password to access the version, we don't have it, as enrollment endpoints don't require username/password but a valid token.
This change allows to configure the client to ignore kibana version check when doing enrollment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Chicken / egg problem here :-)