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

Pid 2645 implement aws secret storage provider #848

Merged

Conversation

martinsaporiti
Copy link
Contributor

No description provided.

@martinsaporiti martinsaporiti requested a review from a team as a code owner November 19, 2024 13:04
Copy link

gitguardian bot commented Nov 19, 2024

⚠️ GitGuardian has uncovered 5 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
14295020 Triggered Generic High Entropy Secret 129144c internal/kms/aws_secret_storage_provider_test.go View secret
8664826 Triggered Generic Password 004c9a9 k8s/helm/values.yaml View secret
14295020 Triggered Generic High Entropy Secret 129144c internal/kms/aws_secret_storage_provider_test.go View secret
14295020 Triggered Generic High Entropy Secret 129144c internal/kms/aws_secret_storage_provider_test.go View secret
14295020 Triggered Generic High Entropy Secret bc715b3 internal/kms/aws_secret_storage_provider_test.go View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@martinsaporiti martinsaporiti self-assigned this Nov 19, 2024
if issuerKMSEthPluginVar != config.LocalStorage && issuerKMSEthPluginVar != config.Vault && issuerKMSEthPluginVar != config.AWS {
log.Error(ctx, "issuer kms eth provider is not set or is not localstorage or vault or aws", "plugin: ", issuerKMSEthPluginVar)
if issuerKMSETHProviderToUse != config.LocalStorage && issuerKMSETHProviderToUse != config.Vault && issuerKMSETHProviderToUse != config.AWS {
log.Error(ctx, "issuer kms eth provider is not set or is not localstorage or vault or aws", "plugin: ", issuerKMSETHProviderToUse)
Copy link
Member

Choose a reason for hiding this comment

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

This error message is messy. Cleaner one would be issuer kms eth provider is invalid, supported values are: localstorage, vault, aws

)

const (
localstackSecretManagerEndpoint = "http://localhost:4566"
Copy link
Member

Choose a reason for hiding this comment

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

  1. It should not be a constant, should be configurable through env vars or config param.
  2. It's default value (coming from the env var / config) should not be localhost, but container name (e.g. http://localstack:4566)
  3. Name should not include "localstack" because user may switch to something else, better use "local" as in the name of key storage config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. ok
  2. ok
  3. I prefer URL for the name of the variable. So AWS config will be:
ISSUER_KMS_AWS_ACCESS_KEY=<aws_access_key>
ISSUER_KMS_AWS_SECRET_KEY=<aws_secret_key>
ISSUER_KMS_AWS_REGION=<aws_region> # if this value is `local` then `ISSUER_KMS_AWS_URL` is used
ISSUER_KMS_AWS_URL=<aws_url> # aws secret store URL

Note: ISSUER_KMS_AWS_REGION=local is for running tests.

localstack:
image: localstack/localstack:latest
ports:
- "4566:4566"
Copy link
Member

Choose a reason for hiding this comment

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

Don't do port forwarding. Please remove the same for other containers (in a separate PR if too many changes are needed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need port forwarding because localstack is used for running tests and those tests are outside docker

}

// NewLocalStorageFileProvider - creates new local storage file manager
func NewLocalStorageFileProvider(file string) StorageManager {
Copy link
Member

Choose a reason for hiding this comment

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

Better rename local storage to file storage everywhere (including in config params and file name, and deprecate local as a storage option, but still support it), so that here we would have NewFileStorageManager (because it returns StorageManager, not StoragePrivider).

Copy link
Member

Choose a reason for hiding this comment

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

@demonsh What do you think about introducing new kms config option file and deprecating local? I think it should be easier to understand what it is and how it works.

return &localStorageFileProvider{file}
}

func (ls *localStorageFileProvider) SaveKeyMaterial(ctx context.Context, keyMaterial map[string]string, id string) error {
Copy link
Member

Choose a reason for hiding this comment

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

*fileStorageManager

PrivateKey string `json:"private_key"`
type localBJJKeyProvider struct {
keyType KeyType
reIdenKeyPathHex *regexp.Regexp // RE of key path bounded to identity
Copy link
Member

Choose a reason for hiding this comment

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

bound, not bounded

type localBJJKeyProvider struct {
keyType KeyType
reIdenKeyPathHex *regexp.Regexp // RE of key path bounded to identity
reAnonKeyPathHex *regexp.Regexp // RE of key path not bounded to identity
Copy link
Member

Choose a reason for hiding this comment

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

same here

KeyType string `json:"key_type"`
KeyPath string `json:"key_path"`
PrivateKey string `json:"private_key"`
type localBJJKeyProvider struct {
Copy link
Member

Choose a reason for hiding this comment

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

fileBJJKeyProvider

Copy link
Contributor Author

Choose a reason for hiding this comment

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

local means that the issuer node handles the creation of the keys unlike Vault or AWS KMS.
localBJJKeyProvider uses a storageManager to store the keys, which can be a text file or an AWS secret manager.

keyType KeyType
reIdenKeyPathHex *regexp.Regexp // RE of key path bounded to identity
localStorageFileManager LocalStorageFileManager
type localEthKeyProvider struct {
Copy link
Member

Choose a reason for hiding this comment

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

fileEthKeyProvider

Copy link
Contributor Author

Choose a reason for hiding this comment

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

local means that the issuer node handles the creation of the keys unlike Vault or AWS KMS.
localETHKeyProvider uses a storageManager to store the keys, which can be a text file or an AWS secret manager.

)

func Test_getKeyID(t *testing.T) {
identity, err := w3c.ParseDID("did:polygonid:polygon:amoy:2qQ68JkRcf3ySMcjPtGKJhGgu7jh4zzhrz6UxpXwPw")
Copy link
Member

Choose a reason for hiding this comment

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

Please use did:iden3

@demonsh demonsh self-requested a review November 27, 2024 18:13
@martinsaporiti martinsaporiti merged commit cc52be0 into develop Dec 2, 2024
3 checks passed
@martinsaporiti martinsaporiti deleted the PID-2645-implement-aws-secret-storage-provider branch December 2, 2024 09:48
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.

3 participants