App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
# AUTHENTICATION
HTTP Basic Authorization is only supported when the `proto` is set to **https**
as not to leak credentials all over.
The username is selected by going through these mechanisms until one is found:
--http-username
'http-username' in /etc/es-utils.yml or ~/.es-utils.yml
Netrc element matching the hostname of the request
CLI::Helpers prompt()
Once the username has been resolved, the following mechanisms are tried in order:
Netrc element matching the hostname of the request
Password executable defined by --password-exec
'password-exec' in /etc/es-utils.yml, ~/.es-utils.yml
CLI::Helpers prompt()
## Password Exec
It is **BAD** practice to specify passwords as a command line argument, or store it in a plaintext
file. There are cases where this may be necessary, but it is not recommended. The best method for securing your
password is to use the **password-exec** option.
This option must point to an executable script. That script will be passed two arguments, the hostname and the username
for the request. It expects the password printed to STDOUT as the last line of output. Here's an example password-exec setup
using Apple Keychain:
README.mkdn view on Meta::CPAN
---
host: secured-cluster.example.org
port: 443
proto: https
http-username: bob
password-exec: /home/bob/bin/get-passwd.sh
### CLI::Helpers and Password Prompting
If all the fails to yield a password, the last resort is to use CLI::Helpers::prompt() to ask the user for their
password. If the user is using version 1.1 or higher of CLI::Helpers, this call will turn off echo and readline magic
for the password prompt.
# INDEX SELECTION ARGUMENTS
- **base**
In an environment using monthly, weekly, daily, or hourly indexes. The base index name is everything without the date.
Parsing for bases, also provides splitting and matching on segments of the index name delineated by the '-' character.
If we have the following indexes:
web-dc1-YYYY.MM.DD
lib/App/ElasticSearch/Utilities.pm view on Meta::CPAN
# Get the Username
$auth{username} ||= $meta{'http-username'} ? $meta{'http-username'}
: defined $DEF{USERNAME} ? $DEF{USERNAME}
: defined $netrc ? $netrc->login
: $ENV{USER};
# Prompt for the password
$auth{password} ||= defined $netrc ? $netrc->password
: (es_pass_exec($host,$auth{username},$meta{'password-exec'})
|| prompt(sprintf "Password for '%s' at '%s': ", $auth{username}, $host)
);
# Store
$_auth_cache{$host} = \%auth;
return @auth{qw(username password)};
}
sub es_pass_exec {
my ($host,$username,$exec) = @_;
lib/App/ElasticSearch/Utilities.pm view on Meta::CPAN
=head1 AUTHENTICATION
HTTP Basic Authorization is only supported when the C<proto> is set to B<https>
as not to leak credentials all over.
The username is selected by going through these mechanisms until one is found:
--http-username
'http-username' in /etc/es-utils.yml or ~/.es-utils.yml
Netrc element matching the hostname of the request
CLI::Helpers prompt()
Once the username has been resolved, the following mechanisms are tried in order:
Netrc element matching the hostname of the request
Password executable defined by --password-exec
'password-exec' in /etc/es-utils.yml, ~/.es-utils.yml
CLI::Helpers prompt()
=head2 Password Exec
It is B<BAD> practice to specify passwords as a command line argument, or store it in a plaintext
file. There are cases where this may be necessary, but it is not recommended. The best method for securing your
password is to use the B<password-exec> option.
This option must point to an executable script. That script will be passed two arguments, the hostname and the username
for the request. It expects the password printed to STDOUT as the last line of output. Here's an example password-exec setup
using Apple Keychain:
lib/App/ElasticSearch/Utilities.pm view on Meta::CPAN
---
host: secured-cluster.example.org
port: 443
proto: https
http-username: bob
password-exec: /home/bob/bin/get-passwd.sh
=head3 CLI::Helpers and Password Prompting
If all the fails to yield a password, the last resort is to use CLI::Helpers::prompt() to ask the user for their
password. If the user is using version 1.1 or higher of CLI::Helpers, this call will turn off echo and readline magic
for the password prompt.
=head1 INDEX SELECTION ARGUMENTS
=over
=item B<base>
In an environment using monthly, weekly, daily, or hourly indexes. The base index name is everything without the date.
Parsing for bases, also provides splitting and matching on segments of the index name delineated by the '-' character.
If we have the following indexes:
( run in 0.960 second using v1.01-cache-2.11-cpan-6aa56a78535 )