-
Notifications
You must be signed in to change notification settings - Fork 76
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
feat: add awskms provider #86
Conversation
return string(result.Plaintext), nil | ||
} | ||
|
||
func (p *provider) GetStringMap(key string) (map[string]interface{}, error) { |
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.
It would be great if you could implement this too!
FYI, GetStringMap
can be implemented on top of GetString
like seen in https://github.com/variantdev/vals/blob/e059ff4fa22925a54038c69a62c51ee500d1c4d2/pkg/providers/s3/s3.go#L71-L82.
It's used when you instructed vals
to parse the decrypted/fetched value as a YAML or a JSON object and retrieve only one value within the object (e.g. when you suffixed the URL with #/yaml_or_json_key/in/secret
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.
I do think it's fairly unlikely that anyone would use the KMS provider in this manner; since the ciphertext needs to be embedded directly into the document (and embedded repeatedly if you need to reference it multiple times), you'd usually just encode the value of the specific value needed at each location rather than encoding a much larger document (which means a correspondingly larger cipher text), and repeating that ciphertext in multiple places with different keys.
Nevertheless, I did go ahead and implement it, so if someone does want to use it this way, they can.
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's definitely a valid point! Thanks for your insight. I'm still glad you made it feature-parity with other providers so that it is at least consistent across the providers and users might potentially find a way to utilize it in practice.
@mumoshu I'm working on addressing your suggestion above, but, I've run into another wrinkle that will also (presumably) affect the SOPS base64 support. I'll have the updated PR shortly (including support for KMS encryption context, key id, etc). In the mean time, if you can think of a better way to make base64 work in a URL, I'm all ears. EDIT: Nevermind, I apparently forgot about URL-safe Base64 encoding. Unfortunately, there's no way to trick the AWS CLI to give you the urlsafe encoding up front, but it's still easier than URL-encoding everything. |
…fix base64 decoding
@mumoshu OK, that's fixed now. |
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.
LGTM. I'd say you're an incredible Golang dev already! Thanks a lot for your contribution
An alternative implementation of the
awskms
provider, inspired by #41.This implementation works the way you suggested it should in #41, with
ref+awskms://BASE64CIPHERTEXT
resolving to the cleartext encoded by said ciphertext. The indirection/ref+vals://
support from #41 is not included.Note that while I have tested this code and it does work, I am not a Go programmer, so I can't really vouch for its quality. In particular, I didn't understand the intended purpose of having the
GetStringMap
function in addition to theGetString
function; even with an empty implementation, theawskms
provider does seem to work, but, I assume it's missing some functionality given that I didn't really properly implement one of the necessary methods.