-
Notifications
You must be signed in to change notification settings - Fork 156
feat: Add Secret handling in OpenSearchDocumentStore #1288
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
Conversation
This one is not ready yet @tstadel 👍 |
@tstadel should be ready now, please be really careful with this one 🙏 |
integrations/opensearch/src/haystack_integrations/document_stores/opensearch/document_store.py
Show resolved
Hide resolved
@vblagoje in general looks good. I'm very confident we don't break anything. But let's please support import yaml
serialized = OpenSearchDocumentStore().to_dict()
yaml_serialized = yaml.safe_dump(serialized)
yaml_deserialized = yaml.safe_load(yaml_serialized)
# http_auth will be [...] and hence secrets not deserialized
deserialzed = OpenSearchDocumentStore.from_dict(yaml_deserialized) |
…res/opensearch/document_store.py Co-authored-by: tstadel <[email protected]>
@tstadel although the init parameters for secrets use tuple they are always serialized as a list as you can see in the tests. I wanted to remain 100% backward compatible here so all changes are focused only on secrets addition and making sure everything else stays the same. |
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.
That works! Thanks for applying the changes! 🚀
* Add Secret handling in OpenSearchDocumentStore * only serialize auth secrets when values are resolvable * Update integrations/opensearch/src/haystack_integrations/document_stores/opensearch/document_store.py Co-authored-by: tstadel <[email protected]> * Fixes * Revert accidental commit * Special list of Secrets handling only, keep everything else as it was before * Small improvement * More simplifications --------- Co-authored-by: tstadel <[email protected]>
Why:
Enhances the authentication mechanism within the OpenSearch integration to allow for sensitive credentials to be managed securely using environment variables.
What:
username
andpassword
) from environment variables using theSecret
class.Secret
objects for secure storage and retrieval of credentials.How can it be used:
Environment variable-based authentication can be leveraged by setting:
Then, initialize the
OpenSearchDocumentStore
as follows:How did you test it:
Testing involved mocking the
OpenSearch
client to verify the correct behavior of the authentication logic, including the execution of environment variable-based initialization and validation of serialized objects to check the correct capture of credentials asSecret
dictionaries.Notes for the reviewer:
Focus on the sections handling the
http_auth
in dict serialization and the test cases for environment-based authentication to ensure consistent and secure handling of credentials. Verify that no credentials are logged or exposed improperly.