-
Notifications
You must be signed in to change notification settings - Fork 537
Add support for multiple keys per secret #3708
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
Add support for multiple keys per secret #3708
Conversation
55b69e7
to
199f60a
Compare
Signed-off-by: Patrick Assuied <[email protected]>
199f60a
to
c7f6258
Compare
Signed-off-by: Patrick Assuied <[email protected]>
Signed-off-by: Patrick Assuied <[email protected]>
Signed-off-by: Patrick Assuied <[email protected]>
This looks like a reasonable approach. The same approach can be used for AWS SSM ParameterStore? Can this be applied to all secret store implementations that don't natively implement multiple values? How performant is formatString on non-json values? By the way, aws-sdk-go reaches end-of-support in a few months. #2155 |
@joebowbeer Happy to contribute further to migrate AWS SDK. We heavily use the dynamodb state store and use other components integrating with AWS. |
I don't have benchmarks but it should fail pretty fast if the first character is not a Also I would expect that consumers would only use this option if they know their secrets have multiple k/v. The structure of the secrets should be known ahead. |
Signed-off-by: Patrick Assuied <[email protected]>
Signed-off-by: Patrick Assuied <[email protected]>
On second look, it looks like this only supports a single level of string-valued keys. At least, I don't see tests for anything else. Note however that arbitrarily nested JSON values are allowed, including values that are JSON objects and arrays. How can these values be extracted? Since reviewing this, I've looked at the AWS provider for Secrets Store CSI Driver, which also supports extracting secrets from json-encoded values: https://github.com/aws/secrets-store-csi-driver-provider-aws In their solution, the user specifies which paths to extract using a JMES path:
I don't think Dapr needs to be concerned with name aliasing and mapping, but it occurs to me that it should be able to handle arbitrarily nested JSON. I also think it should have a strategy for creating the keys for the nested values. For example, by combining the parts using a default separator such as '/' and allowing the user to specify a different separator such as '.'. Another place to look for ideas is the AWS provider for External Secrets Operator: https://external-secrets.io/latest/provider/aws-secrets-manager/#json-secret-values |
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.
Given that values can be arbitrarily nested JSON, the tests and docs should be extended to cover how nested values are extracted, including objects and arrays.
@joebowbeer the DAPR secretstores interface only supports 1 level and any sub level will be left as a string. I can definitely add more tests to reflect but I don't think we can do anything else to support nested JSON use cases. |
Make sure to properly deserialize an stringify in those use cases. Signed-off-by: Patrick Assuied <[email protected]>
@joebowbeer turns out your call was very important. given the unmarshalling to map[string]string, the setting would NOT work in case of nested values. |
Signed-off-by: Patrick Assuied <[email protected]>
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.
Is there a test for top-level array values? They are used with rotating secrets.
Wouldn't you use |
Signed-off-by: Patrick Assuied <[email protected]>
Here's some test input from the docs: {
"awsSeamlessDomainDirectoryId": "d-12345abc6e",
"awsSeamlessDomainUsername": "<username>",
"awsSeamlessDomainPassword": "<password>",
"directoryServiceSecretVersion": 1,
"schemaVersion": "1.0",
"keytabArns": [
"<ARN of child keytab secret 1>",
"<ARN of child keytab secret 2>",
"<ARN of child keytab secret 3>",
],
"lastModifiedDateTime": "2021-07-19 17:06:58"
} |
So really the secret is still an object and not a collection. So the nested test case would cover it... |
Thanks for the implementation PR - Can you open a PR for this to the dapr/docs repo adding the new optional field to this page? |
Signed-off-by: Patrick Assuied <[email protected]>
Signed-off-by: Patrick Assuied <[email protected]>
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.
thx for the update! it just reads consistently with the err != nil, its a nit, but for overall readability :)
ee56d17
to
58bb06d
Compare
@joebowbeer you seem to have some good AWS experience. Could you review again with the AWS SDK v2 implementation? Especially the x509 auth support... I cannot find a ton of doc online whether this approach is sound or not... Based on this doc, it seems like v2 may handle refresh and a lot of the complexity introduced in x509.go file but I'm not sure this is the case... |
@passuied I think the AWS v2 auth package needs to be thought through before using AWS v2 auth in secretsmanager. Consider adding a separate package for AWS v2 auth. https://github.com/dapr/components-contrib/blob/main/common/authentication/aws2 ? https://github.com/dapr/components-contrib/blob/main/common/authentication/aws/client2.go ? This decision should be made before accruing more v2 logic in the existing client. Currently the AWS v2 support in client is isolated to MSK. |
Thanks @joebowbeer. Any thoughts on the x509 support in place? I had assumed that was what was involved in making auth work in EKS under a service account role but it doesn't seem to be connected... @yaron2 any guidance on needed support for aws sdk v2? Do we still need it? Should I be creating a separate x509 implementation for v2? |
@passuied I suggest reverting v2 changes. When migrating to v2, all aws refs should be migrated. But at the moment, I see v2 code calling some aws functions. It's better to add your feature first, and then migrate to v2, which has a much bigger blast radius. I don't know why the x509 changes were made. I can't see how they are related to your feature or v2 migration. |
564ba78
to
c14b496
Compare
@joebowbeer I took your advice and will be working on this separately. I still would like to be able to migrate these to v2 one component at a time to avoid a huge PR but I'd rather get this feature merged sooner. |
#3856 V2 package PR - just investigating whether my changes to the snssqs component have caused the failures or the package which I doubt |
@mikeee not sure what you mean by failures here... |
@mikeee if you can review and approve this PR I can create a subsequent one that will upgrade secrets manager to v2 |
Description
AWS Secrets manager secrets store currently doesn't support multiple keys per secret. This would be a very useful feature.
We can make it backwards compatible by adding a new optional metadata value MultipleKeyValuesPerSecret
Also upgrade AWS sdk to v2Issue reference
#3707
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: