Skip to content

Allow user/passwd based enrollment#8524

Merged
exekias merged 2 commits intoelastic:feature/centralmgmtfrom
exekias:password-enrollment
Oct 1, 2018
Merged

Allow user/passwd based enrollment#8524
exekias merged 2 commits intoelastic:feature/centralmgmtfrom
exekias:password-enrollment

Conversation

@exekias
Copy link
Copy Markdown
Contributor

@exekias exekias commented Oct 1, 2018

This allows to enroll using the following workflow:

$ <beat> enroll http://kibana:5601
Enter password:

Enrolled and ready to retrieve settings from Kibana

It also allows to pass the password as an env variable:

$ PASS=...
$ <beat> enroll http://kibana:5601 --username elastic --password env:PASS

Enrolled and ready to retrieve settings from Kibana

This allows to enroll using the following workflow:

```
$ <beat> enroll http://kibana:5601 --username elastic
Enter password:

Enrolled and ready to retrieve settings from Kibana
```

It also allows to pass the password as an env variable:

```
PASS=...
$ <beat> enroll http://kibana:5601 --username elastic --password env:PASS

Enrolled and ready to retrieve settings from Kibana
```
@exekias
Copy link
Copy Markdown
Contributor Author

exekias commented Oct 1, 2018

@andrewkroh thank you for your input on this, could you please have a look?

Copy link
Copy Markdown
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call making it reusable.

For everyone else's benefit, we discussed making this similar to openssl which allows passwords to be provided in several ways so that the user has the option of not putting a password into the CLI args.

}

// 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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/it/It/


m := methods[method]
if m == nil {
return "", fmt.Errorf("unknown password retrieval method %s", method)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will likely result in passwords inadvertently being echo'ed to the console. I think user's will expect that they can use --password=<password>. Rather than including the user's argument in the message you could list the allowed formats (like unknown password source (use stdin or env:var)).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point here, I would expect some users making that mistake


var method, params string
parts := strings.SplitN(def, ":", 2)
method = parts[0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd normalize the value with strings.ToLower.

@exekias
Copy link
Copy Markdown
Contributor Author

exekias commented Oct 1, 2018

thank you @andrewkroh, I've pushed: 3094da5

@exekias exekias merged commit 7ac4f35 into elastic:feature/centralmgmt Oct 1, 2018
exekias added a commit that referenced this pull request Oct 4, 2018
* Beats enrollment subcommand (#7182)

This PR implements intial enrollment to Central Management in Kibana. After running the enrollment command, beats will have a valid access token to use when retrieving configurations.

To test this:

- Use the following branches:
  - Elasticsearch: https://github.com/ycombinator/elasticsearch/tree/x-pack/management/beats
  - Kibana: https://github.com/elastic/kibana/tree/feature/x-pack/management/beats
- Retrieve a valid enrollment token:
```
curl  \                             
  -u elastic \           
  -H 'kbn-xsrf: foobar'  \
  -H 'Content-Type: application/json' \
  -X POST \
  http://localhost:5601/api/beats/enrollment_tokens
```
- Use it:
```
<beat> enroll http://localhost:5601 <enrollment_token>
```
- Check agent is enrolled:
```
curl http://localhost:5601/api/beats/agents | jq
```

This is part of #7028, closes #7032

* Add API client to retrieve configurations from CM (#8155)

* Add central management service (#8263)

* Add config manager initial skeleton

Config manager will poll configs from Kibana and apply them locally. It must be
started with the beat.

In order to check the user is not trying to override configurations
provided by central management, the Config Manager can check the exisitng
configuration and return errors if something is wrong.

* Register output for reloading (#8378)

* Also send beat name when enrolling (#8380)

* Refactor how configs are stored (#8379)

* Refactor configs storage to avoid YAML issues

* Refactor manager loop to avoid repeated code

* Use beat name var when registering confs (#8435)

This should make Auditbeat or any other beat based on Metricbeat have
their own namespace for confs

* Allow user/passwd based enrollment (#8524)

* Allow user/passwd based enrollment

This allows to enroll using the following workflow:

```
$ <beat> enroll http://kibana:5601 --username elastic
Enter password:

Enrolled and ready to retrieve settings from Kibana
```

It also allows to pass the password as an env variable:

```
PASS=...
$ <beat> enroll http://kibana:5601 --username elastic --password env:PASS

Enrolled and ready to retrieve settings from Kibana
```

* Fix some strings after review comments

* Add changelog
exekias added a commit to exekias/beats that referenced this pull request Oct 16, 2018
* Beats enrollment subcommand (elastic#7182)

This PR implements intial enrollment to Central Management in Kibana. After running the enrollment command, beats will have a valid access token to use when retrieving configurations.

To test this:

- Use the following branches:
  - Elasticsearch: https://github.com/ycombinator/elasticsearch/tree/x-pack/management/beats
  - Kibana: https://github.com/elastic/kibana/tree/feature/x-pack/management/beats
- Retrieve a valid enrollment token:
```
curl  \
  -u elastic \
  -H 'kbn-xsrf: foobar'  \
  -H 'Content-Type: application/json' \
  -X POST \
  http://localhost:5601/api/beats/enrollment_tokens
```
- Use it:
```
<beat> enroll http://localhost:5601 <enrollment_token>
```
- Check agent is enrolled:
```
curl http://localhost:5601/api/beats/agents | jq
```

This is part of elastic#7028, closes elastic#7032

* Add API client to retrieve configurations from CM (elastic#8155)

* Add central management service (elastic#8263)

* Add config manager initial skeleton

Config manager will poll configs from Kibana and apply them locally. It must be
started with the beat.

In order to check the user is not trying to override configurations
provided by central management, the Config Manager can check the exisitng
configuration and return errors if something is wrong.

* Register output for reloading (elastic#8378)

* Also send beat name when enrolling (elastic#8380)

* Refactor how configs are stored (elastic#8379)

* Refactor configs storage to avoid YAML issues

* Refactor manager loop to avoid repeated code

* Use beat name var when registering confs (elastic#8435)

This should make Auditbeat or any other beat based on Metricbeat have
their own namespace for confs

* Allow user/passwd based enrollment (elastic#8524)

* Allow user/passwd based enrollment

This allows to enroll using the following workflow:

```
$ <beat> enroll http://kibana:5601 --username elastic
Enter password:

Enrolled and ready to retrieve settings from Kibana
```

It also allows to pass the password as an env variable:

```
PASS=...
$ <beat> enroll http://kibana:5601 --username elastic --password env:PASS

Enrolled and ready to retrieve settings from Kibana
```

* Fix some strings after review comments

* Add changelog

(cherry picked from commit 4247bc3)
exekias added a commit that referenced this pull request Oct 18, 2018
* Add Central Management feature (#8559)

* Beats enrollment subcommand (#7182)

This PR implements intial enrollment to Central Management in Kibana. After running the enrollment command, beats will have a valid access token to use when retrieving configurations.

To test this:

- Use the following branches:
  - Elasticsearch: https://github.com/ycombinator/elasticsearch/tree/x-pack/management/beats
  - Kibana: https://github.com/elastic/kibana/tree/feature/x-pack/management/beats
- Retrieve a valid enrollment token:
```
curl  \
  -u elastic \
  -H 'kbn-xsrf: foobar'  \
  -H 'Content-Type: application/json' \
  -X POST \
  http://localhost:5601/api/beats/enrollment_tokens
```
- Use it:
```
<beat> enroll http://localhost:5601 <enrollment_token>
```
- Check agent is enrolled:
```
curl http://localhost:5601/api/beats/agents | jq
```

This is part of #7028, closes #7032

* Add API client to retrieve configurations from CM (#8155)

* Add central management service (#8263)

* Add config manager initial skeleton

Config manager will poll configs from Kibana and apply them locally. It must be
started with the beat.

In order to check the user is not trying to override configurations
provided by central management, the Config Manager can check the exisitng
configuration and return errors if something is wrong.

* Register output for reloading (#8378)

* Also send beat name when enrolling (#8380)

* Refactor how configs are stored (#8379)

* Refactor configs storage to avoid YAML issues

* Refactor manager loop to avoid repeated code

* Use beat name var when registering confs (#8435)

This should make Auditbeat or any other beat based on Metricbeat have
their own namespace for confs

* Allow user/passwd based enrollment (#8524)

* Allow user/passwd based enrollment

This allows to enroll using the following workflow:

```
$ <beat> enroll http://kibana:5601 --username elastic
Enter password:

Enrolled and ready to retrieve settings from Kibana
```

It also allows to pass the password as an env variable:

```
PASS=...
$ <beat> enroll http://kibana:5601 --username elastic --password env:PASS

Enrolled and ready to retrieve settings from Kibana
```

* Fix some strings after review comments

* Add changelog

(cherry picked from commit 4247bc3)

* Fix monitoring registry usage
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
* Allow user/passwd based enrollment

This allows to enroll using the following workflow:

```
$ <beat> enroll http://kibana:5601 --username elastic
Enter password:

Enrolled and ready to retrieve settings from Kibana
```

It also allows to pass the password as an env variable:

```
PASS=...
$ <beat> enroll http://kibana:5601 --username elastic --password env:PASS

Enrolled and ready to retrieve settings from Kibana
```

* Fix some strings after review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants