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

Pass in initialAdminPassword #669

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/opensearch/Dockerfile.opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ ARG SECURE_INTEGRATION
HEALTHCHECK --start-period=20s --interval=5s --retries=2 --timeout=1s \
CMD if [ "$SECURE_INTEGRATION" != "true" ]; \
then curl --fail localhost:9200/_cat/health; \
else curl --fail -k https:/localhost:9200/_cat/health -u admin:admin; fi
else curl --fail -k https:/localhost:9200/_cat/health -u admin:myStrongPassword123!; fi
Copy link
Member

Choose a reason for hiding this comment

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

Should this change be version based? admin for <2.12 and myStrongPassword123! for >=2.12.


RUN if [ "$SECURE_INTEGRATION" != "true" ] ; then $opensearch_path/bin/opensearch-plugin remove opensearch-security; fi
1 change: 1 addition & 0 deletions .ci/opensearch/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- discovery.type=single-node
- bootstrap.memory_lock=true
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
Copy link
Collaborator

Choose a reason for hiding this comment

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

@DarshitChanpura with OS 2.12 and Up, would this be enough to set the admin password? Does the plugin just grab what stored in OPENSEARCH_INITIAL_ADMIN_PASSWORD, check if it's strong enough, and then assign it as password for admin user?

Copy link
Collaborator

@nhtruong nhtruong Jan 29, 2024

Choose a reason for hiding this comment

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

I also saw this in the security plugin repo: https://github.com/opensearch-project/security/pull/3843/files
Does that mean that if we set initialAdminPassword to myStrongPassword123!, that password will also work for older version of OS?

Copy link
Member

Choose a reason for hiding this comment

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

@DarshitChanpura with OS 2.12 and Up, would this be enough to set the admin password? Does the plugin just grab what stored in OPENSEARCH_INITIAL_ADMIN_PASSWORD, check if it's strong enough, and then assign it as password for admin user?

Yes, that is correct. The env variable will be picked up when running demo configuration.

I also saw this in the security plugin repo: https://github.com/opensearch-project/security/pull/3843/files
Does that mean that if we set initialAdminPassword to myStrongPassword123!, that password will also work for older version of OS?

There is no concept of custom admin passwords for versions prior to 2.12. This will be introduced in 2.12 and will be required henceforth when using security plugin's demo configuration. Please note that variable is OPENSEARCH_INITIAL_ADMIN_PASSWORD and not initialAdminPassword.

ports:
- '9200:9200'
user: opensearch
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bumps `@aws-sdk/types` from 3.451.0 to 3.468.0
- Bumps `prettier` from 3.1.0 to 3.1.1
### Changed
- Pass in `OPENSEARCH_INITIAL_ADMIN_PASSWORD` to docker and update instances of admin:admin in READMEs. ([669](https://github.com/opensearch-project/opensearch-js/pull/669))
### Deprecated
### Removed
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var host = 'localhost';
var protocol = 'https';
var port = 9200;
var auth = 'admin:admin'; // For testing only. Don't store credentials in code.
var auth = `admin:<admin password>`; // For testing only. Don't store credentials in code.
var ca_certs_path = '/full/path/to/root-ca.pem';

// Optional client certificates if you don't want to use HTTP basic authentication.
Expand Down
2 changes: 1 addition & 1 deletion guides/advanced_index_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Let's create a client instance, and an index named `movies`:
```javascript
const { Client } = require('@opensearch-project/opensearch');
const client = new Client({
node: 'https://admin:admin@localhost:9200',
node: `https://admin:<admin password>@localhost:9200`,
ssl: { rejectUnauthorized: false }
});
client.indices.create({index: 'movies'})
Expand Down
4 changes: 2 additions & 2 deletions guides/index_lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This guide covers OpenSearch JavaScript Client API actions for Index Lifecycle.

## Setup

In this guide, we will need an OpenSearch cluster with more than one node. Let's use the sample [docker-compose.yml](https://opensearch.org/samples/docker-compose.yml) to start a cluster with two nodes. The cluster's API will be available at `localhost:9200` with basic authentication enabled with default username and password of `admin:admin`.
In this guide, we will need an OpenSearch cluster with more than one node. Let's use the sample [docker-compose.yml](https://opensearch.org/samples/docker-compose.yml) to start a cluster with two nodes. The cluster's API will be available at `localhost:9200` with basic authentication enabled with default username and password of `admin:<admin password>`.

To start the cluster, run the following command:

Expand All @@ -18,7 +18,7 @@ Let's create a client instance to access this cluster:
const { Client } = require('@opensearch-project/opensearch');

const client = new Client({
node: 'https://admin:admin@localhost:9200',
node: `https://admin:<admin password>@localhost:9200`,
ssl: { rejectUnauthorized: false }
});

Expand Down
2 changes: 1 addition & 1 deletion guides/msearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OpenSearch's Multi-Search (`msearch`) API allows you to execute multiple search
const host = "localhost";
const protocol = "https";
const port = 9200;
const auth = "admin:admin";
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
const auth = `admin:<admin password>`;
const ca_certs_path = "/full/path/to/root-ca.pem";
const { Client } = require("@opensearch-project/opensearch");
const fs = require("fs");
Expand Down
2 changes: 1 addition & 1 deletion guides/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Let's start by creating an index and adding some documents to it:
var host = "localhost";
var protocol = "https";
var port = 9200;
var auth = "admin:admin"; // For testing only. Don't store credentials in code.
var auth = `admin:<admin password>`; // For testing only. Don't store credentials in code.
var ca_certs_path = "/full/path/to/root-ca.pem";

// Optional client certificates if you don't want to use HTTP basic authentication.
Expand Down
Loading