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

Conversation

derek-ho
Copy link

Description

Due to recent changes in the security plugin, the install demo configuration script now requires an initial admin password to be set. This sets it to some random variable so that the CI continues to work.

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

Check List

  • New functionality includes testing.
    • All tests pass
  • Linter check was successfull - yarn run lint doesn't show any errors
  • Commits are signed per the DCO using --signoff
  • Changelog was updated.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

To fix CI don't you just need to say initialAdminPassword=admin in docker-compose.yml?

I think the documentation should be left alone. Or we should explain how to obtain that initial password.

Signed-off-by: Derek Ho <dxho@amazon.com>
@derek-ho
Copy link
Author

derek-ho commented Dec 13, 2023

To fix CI don't you just need to say initialAdminPassword=admin in docker-compose.yml?

I think the documentation should be left alone. Or we should explain how to obtain that initial password.

Since "admin" is considered a weak password, this wouldn't be possible. There is weak validation in place, and it needs a strong password. Password validation is being done via this library: https://github.com/dropbox/zxcvbn. It is possible to pass in a weak password if running the install-demo-configuraiton script by yourself, but if you are using the distributions we don't currently support it.

@dblock
Copy link
Member

dblock commented Dec 13, 2023

To fix CI don't you just need to say initialAdminPassword=admin in docker-compose.yml?
I think the documentation should be left alone. Or we should explain how to obtain that initial password.

Since "admin" is considered a weak password, this wouldn't be possible. There is weak validation in place, and it needs a strong password. Password validation is being done via this library: https://github.com/dropbox/zxcvbn. It is possible to pass in a weak password if running the install-demo-configuraiton script by yourself, but if you are using the distributions we don't currently support it.

I see. I think we should hardcode a non-readable password in our docker setup.

I would say admin:<initial password> rather than ${initialAdminPassword} that implies some kind of variable.

Signed-off-by: Derek Ho <dxho@amazon.com>
@derek-ho
Copy link
Author

To fix CI don't you just need to say initialAdminPassword=admin in docker-compose.yml?
I think the documentation should be left alone. Or we should explain how to obtain that initial password.

Since "admin" is considered a weak password, this wouldn't be possible. There is weak validation in place, and it needs a strong password. Password validation is being done via this library: https://github.com/dropbox/zxcvbn. It is possible to pass in a weak password if running the install-demo-configuraiton script by yourself, but if you are using the distributions we don't currently support it.

I see. I think we should hardcode a non-readable password in our docker setup.

I didn't get this point - do you just mean something that is random/doesn't contain whole words?

I would say admin:<initial password> rather than ${initialAdminPassword} that implies some kind of variable.

Done

Signed-off-by: Derek Ho <dxho@amazon.com>
@derek-ho
Copy link
Author

@dblock @nhtruong can you take another look at this PR? I'm wondering as to why the CI doesn't break, since admin:myStrongPassword123! shouldn't work on secure clusters until 2.12.0 is released. Let me know what you folks think is an appropriate path forward for this PR, thanks! CIs of other PRs are also passing, so I am suspecting we may not even need this PR - I don't think the healthcheck command is working correctly.

@DarshitChanpura
Copy link
Member

@dblock @nhtruong Can we get more reviews on this PR?

@dblock
Copy link
Member

dblock commented Jan 17, 2024

@DarshitChanpura take a look at @derek-ho's comment above.

  1. Why is this not breaking?
  2. Do we need this change before 2.12?

@derek-ho
Copy link
Author

Putting this PR in draft until 2.12.0 is released, since it looks like the workflows are only using released docker versions from opensearchproject. I am still confused why changing the healthcheck command to non - "admin" password is still passing, since released versions up until now should not take up the new password. Maybe something to look into after release.

@derek-ho derek-ho marked this pull request as draft January 22, 2024 15:38
@DarshitChanpura
Copy link
Member

DarshitChanpura commented Jan 22, 2024

@dblock, Derek and I are looking to get feedback from maintainers here to understand whether CI is run against 2.12 and if so is there any codepath that we should address. Right now, based on our understanding, we suspect that the health checks might not be working, and we would like the feedback on the path forward for this PR.

We are not familiar with this code-base and initially raised this PR (and others across different repositories) to help with the changes needed as part of larger effort: opensearch-project/security#3624 and are seeking guidance from maintainers on the path forward. Here are some questions we had:

  1. Is CI run against 2.12?
  2. Is there any branching strategy required moving forward to pick admin password for requests against < 2.12?
  3. If the CI is not run against 2.12, why is health check passing with the new password?

@nhtruong
Copy link
Collaborator

nhtruong commented Jan 22, 2024

@DarshitChanpura

  1. CI is running against 2.x and main: https://github.com/opensearch-project/opensearch-js/blob/main/.github/workflows/integration-unreleased.yml#L24-L25
  2. Shouldn't the password used in this PR work against < 2.12 too?

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

  1. CI is running against 2.x and main: https://github.com/opensearch-project/opensearch-js/blob/main/.github/workflows/integration-unreleased.yml#L24-L25

If I am reading the workflow right, the workflow uses min OpenSearch distribution in which case security will not be installed (as it doesn't exist as part of min distribution) and no admin password is required.

  1. Shouldn't the password used in this PR work against < 2.12 too?

The password change is only for versions 2.12 and later. For versions <2.12 the password is still admin.

@@ -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.

@nhtruong
Copy link
Collaborator

nhtruong commented Jan 23, 2024

If I am reading the workflow right, the workflow uses min OpenSearch distribution in which case security will not be installed (as it doesn't exist as part of min distribution) and no admin password is required.

The CI uses 2 different configuration for security: On and Off https://github.com/opensearch-project/opensearch-js/blob/main/.ci/opensearch/Dockerfile.opensearch#L14

I believe we need to turn it on for that workflow like this and run this set of tests instead.

@DarshitChanpura
Copy link
Member

DarshitChanpura commented Jan 23, 2024

The CI uses 2 different configuration for security: On and Off https://github.com/opensearch-project/opensearch-js/blob/main/.ci/opensearch/Dockerfile.opensearch#L14

@nhtruong Correct, integration-unreleased.yml workflow seems to be using a min distribution of opensearch:

which is what you originally referred to here: #669 (comment)

@DarshitChanpura
Copy link
Member

For released versions workflow integration.yml the changes introduced in this PR (with a modification I suggested above) will be required once 2.12 is released and added to the workflow matrix

@nhtruong
Copy link
Collaborator

nhtruong commented Jan 23, 2024

The password change is only for versions 2.12 and later. For versions <2.12 the password is still admin.

We can make the tests using security plugin to pull password from an env variable and have it fallback to admin if the variable does not exist.

@DarshitChanpura
Copy link
Member

We can make the tests using security plugin to pull password from an env variable and have it fallback to admin if the variable does not exist.

That fallback simply won't work as there is a strong password check in place and admin is not a strong password.

The proposed approach here is to conditionally use the custom (e.g. myStrongPassword123!) / default (admin) password based on the version being tested.

@nhtruong
Copy link
Collaborator

I meant setting the client's env var to the strong password when we use 2.12 and up. But either works :)

@DarshitChanpura
Copy link
Member

DarshitChanpura commented Jan 23, 2024

@nhtruong Sounds good. Would you as a maintainer would like to help suggest/make necessary changes to bring this to completion?

@nhtruong
Copy link
Collaborator

@DarshitChanpura for sure. Lemme find a good stopping point for my current project before switching context. I will be able get on this tomorrow or Thu.

@DarshitChanpura
Copy link
Member

Ty so much @nhtruong !!

@nhtruong
Copy link
Collaborator

I've started taking a crack at this. Will create a new PR but leaving this open for discussion.

@DarshitChanpura
Copy link
Member

I've started taking a crack at this. Will create a new PR but leaving this open for discussion.

Thank you @nhtruong. Btw, as a maintainer you should have access to pushing changes directly on this PR.
You can simply checkout this PR: gh pr checkout 669 and starting commiting/pushing the changes.

@nhtruong
Copy link
Collaborator

Cant push to someone else's protected branch (main) unfortunately. Imma create a new draft to avoid spamming yall with notifications anyway.

@@ -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.

@DarshitChanpura
Copy link
Member

Closing this PR in lieu of #707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants