question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR: Read just specified keys

See original GitHub issue

Hi.

Thanks for great library.

We don’t allow our applications in production to enumerate secrets in account. Instead we give them one or several full paths to secrets that app will need and it can access only them.

I can provide a PR, but I’m not sure how to approach this. E.g. we can provide something like AllowedKeys as a property in SecretsManagerConfigurationProviderOptions and if it’s not empty just get only those keys instead of enumerating all of them.

Would you accept such a PR? Or, probably, you have better idea how to implement this feature?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
alexisatkinsoncommented, Aug 4, 2020

Have you thought about playing with the secrets visible to the IAM role used by the application?

The library would only enumerate through the keys visible to your application.

I had a similar requirement. In terms of permissions, the extension requires kms:Decrypt, kms:Encrypto, secretsmanager:ListSecrets and secretsmanager:GetSecretValue.

If anyone is in a similar boat and can alter the IAM Policy attached to the role/user/group then something like the following works:

{ “Version”: “2012-10-17”, “Statement”: [ { “Sid”: “”, “Effect”: “Allow”, “Action”: [ “kms:Decrypt”, “kms:Encrypt”, “secretsmanager:ListSecrets” ], “Resource”: “*” }, { “Sid”: “”, “Effect”: “Allow”, “Action”: “secretsmanager:GetSecretValue”, “Resource”: “list urn for the secret you want to allow here” } ] }

You can’t specify individual Urns for ListSecrets, but can for GetSecretValue and so it’s possible to restrict access in this way. Then, depending on the environment, you can specify the urn’s to be allowed for that environment and then use the SecretFilter functionality so that GetSecretValue is only called on the whitelisted urn’s e.g:

                    var accepted_urns = GetAcceptedUrns(hostingContext.HostingEnvironment.EnvironmentName);
                    config.AddSecretsManager(configurator: options =>
                    {
                        options.SecretFilter = entry => accepted_urns.Contains(entry.ARN);
                   }

This approach does mean that the application sees the urn of all secret keys with the LIstSecrets functionality, but is only able to retreive the secret keys that relate to the environment the user has access to.

1reaction
Kralizekcommented, Nov 27, 2020

I don’t have an ETA to be frank. I am between jobs right now so you can understand it’s hard for me to find the time for this.

As for every open source project, contributions from the user base are always welcome, even if just to create a PoC.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrieve only specific keys from collection - firebase
Firebase's Web/JavaScript API always returns the full tree under the nodes that you request. The most common workaround for this is that people ......
Read more >
Read a key sequence only from a specified keymap
Is there a way to prompt the user for a key sequence, like read-key-sequence , but only including keys from a specified keymap?...
Read more >
No rows exist for the specified keys in Component Interface ...
No rows exist for the specified keys in Component Interface LOCATION ... If this is a custom AE, you cannot just use the...
Read more >
There are no table entries found for specified key..????
Hi..... Experts.... I created one custom table with four fields... 1. MANDT. 2. E-ID (char10). 3. E-TYPE. 4. E-DESC. here first two are...
Read more >
READE (Read Equal Key)
If the full key of the next record is equal to that of the current record, the next record in the file is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found