Skip to content

Conversation

@kuzaxak
Copy link

@kuzaxak kuzaxak commented Jul 26, 2022

SDK documentation was found here. Service implemented in the same way as GCP KMS.

THis PR adding support for YC KMS as an encryption provider.

Resolves issue #1052

@kuzaxak kuzaxak changed the title Add YC KMS provider support [WIP] Add YC KMS provider support Jul 26, 2022
@astreter astreter force-pushed the yc-kms-support branch 3 times, most recently from 5017148 to ae59188 Compare July 29, 2022 11:57
@kuzaxak kuzaxak changed the title [WIP] Add YC KMS provider support Add YC KMS provider support Jul 29, 2022
@kuzaxak
Copy link
Author

kuzaxak commented Jul 29, 2022

@hiddeco Could you review pls? What else should be added \ updated?

@hiddeco hiddeco self-requested a review July 29, 2022 14:58
@hiddeco
Copy link
Member

hiddeco commented Jul 29, 2022

Have put this on my review list but it might take some time before I can take a proper look at it, as I am not too familiar with the YC KMS client.

@kuzaxak
Copy link
Author

kuzaxak commented Jul 29, 2022

Have put this on my review list but it might take some time before I can take a proper look at it, as I am not too familiar with the YC KMS client.

Thank you!

@hiddeco
Copy link
Member

hiddeco commented Jul 29, 2022

One of the things I can see by quickly scanning this is that it seems to lack a way to overwrite the credentials being used, as was made possible by all my rewritten implementations.

This has proven to be of importance when you want to integrate SOPS in another Go application while not relying on runtime environment variables, you can probably get an idea of what I am aiming at by looking at e.g. https://github.com/mozilla/sops/blob/develop/azkv/keysource.go#L97-L111 (or any of the other key source implementations).

In addition: generally speaking, every time a request is made the key is reconstructed for that specific request anyway (as can be seen in keyservice/server.go). So there is little benefit to embedding the client into the key for re-usage purposes (other than maybe ensuring that the HTTP transport continues to be reused).

@kuzaxak
Copy link
Author

kuzaxak commented Aug 3, 2022

This has proven to be of importance when you want to integrate SOPS in another Go application while not relying on runtime environment variables, you can probably get an idea of what I am aiming at by looking at e.g. https://github.com/mozilla/sops/blob/develop/azkv/keysource.go#L97-L111 (or any of the other key source implementations).

Thank you for detailed feedback. I didn't understand that part and decided to skip it.

I think it is easy to fix and we will do that.

In addition: generally speaking, every time a request is made the key is reconstructed for that specific request anyway (as can be seen in keyservice/server.go). So there is little benefit to embedding the client into the key for re-usage purposes (other than maybe ensuring that the HTTP transport continues to be reused).

Does it mean that we should move client out of the Key structure?

@astreter cc

@hiddeco
Copy link
Member

hiddeco commented Aug 3, 2022

Does it mean that we should move client out of the Key structure?

Yes, I think it would be best to move the client out and replace it with authentication configuration.

@kuzaxak
Copy link
Author

kuzaxak commented Aug 9, 2022

@hiddeco Implemented ability to pass credentials programmatically and cleaned up tests a bit.

Client instance is created every time as you suggested. To implement tests properly I used GCP approach with passing grpcConn directly.

@kuzaxak
Copy link
Author

kuzaxak commented Aug 22, 2022

@hiddeco Hey. Small ping :) We fixed your comments and it will awesome if you could check them.

@kuzaxak
Copy link
Author

kuzaxak commented Aug 31, 2022

Hi, @ajvb I know you are busy, but could you please have a look at PR? I see that @hiddeco is busy, and maybe you have time for it :)

@kuzaxak
Copy link
Author

kuzaxak commented Oct 25, 2022

@hiddeco @ajvb

Hi, we implemented fixes that you requested and it would be great if you can make a review.

@kuzaxak
Copy link
Author

kuzaxak commented Mar 4, 2023

@hiddeco @ajvb

Could you please have a look?

@hiddeco
Copy link
Member

hiddeco commented Mar 4, 2023

Have no rights to merge at present, which means my review wouldn't mean much until this is resolved. Which is something I am actively working on together with others.

@Sebor
Copy link

Sebor commented Mar 7, 2023

Unfortunately, I think that all PRs are frozen until the issue is resolved.

@hiddeco hiddeco added this to the v3.9.0 milestone Jul 4, 2023
@sharovmerk
Copy link

any news here?

@sharovmerk
Copy link

Any news? :)

@felixfontein felixfontein modified the milestones: v3.9.0, 3.10.0 Jun 26, 2024
@chaporgin
Copy link

Can this be merged?

@chaporgin
Copy link

@kuzaxak do you feel like updating this PR?

@kuzaxak
Copy link
Author

kuzaxak commented Dec 25, 2024

@kuzaxak do you feel like updating this PR?

Yes, I can look into it next year

Vladimir Kuznichenkov and others added 2 commits December 26, 2024 22:08
SDK documentation was found [here][1]. Service implemented in the same way as GCP KMS.

This is initial commit which provides basic functionality to encrypt and decrypt files.

Operations with keys via CLI wasn't added, will be added later.
Tests and documentation will be added in the next commit.

Resolves issue getsops#1052

Signed-off-by: Vladimir Kuznichenkov <[email protected]>

[1]: https://cloud.yandex.com/en/docs/kms/tutorials/encrypt/sdk#auth
gRPC calls `Encrypt` and `Decrypt` are mocked with dummy responses
using base64 instead of actual encryption.

Since YC KMS response with binary data we are storing it as base64, together
with mocked server where we encode it one more time instead of actual encryption
we are using double encoding and double decoding in tests cases.

Signed-off-by: Vladimir Kuznichenkov <[email protected]>
@kuzaxak
Copy link
Author

kuzaxak commented Dec 26, 2024

Got a bit of time during Christmas. Rebased the changes, tested locally, works fine. Could you please review @felixfontein

CC @chaporgin

@chaporgin
Copy link

Hey, @felixfontein can you please have a look when you have time? Thank you in advance!

return nil, fmt.Errorf("cannot create YC KMS service: %w", err)
}

decodedCipher, err := base64.StdEncoding.DecodeString(string(key.EncryptedDataKey()))

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.
@sercandumansiz
Copy link

Looking forward to the PR being approved. Thanks for the contribution. 🙌

@ismail-sener
Copy link

We have used it successfully with other providers and want to use YC KMS with SOPS. Thanks for your support. :)

@felixfontein
Copy link
Contributor

Hey, @felixfontein can you please have a look when you have time? Thank you in advance!

I'm very sorry, but I currently have only very limited time, and I will very likely not spend it on reviewing this (or any other new cloud based KMS PR) PR. Maybe someone else from the maintainer team has time, but I don't.

(Generally I would prefer to have a pluggable system where new KMSes (or stores) can be added without having to modify SOPS itself. That would simplify maintaining SOPS and at the same time make supporting new KMSes, or adding larger features to existing ones, a lot easier. Unfortunately that requires quite some legwork, and I currently don't have time to work on that as well...)

@sercandumansiz
Copy link

The timing issue is completely understandable, and I appreciate you keeping us informed.
@chaporgin , who do you think would be the person to handle this?
Thank you for your continued support.

@chaporgin
Copy link

Don't consider this wide ping spam, but m.b. one of @hiddeco, @onedr0p, @devstein have time to review/approve this?

@chaporgin
Copy link

@hiddeco, @onedr0p, @devstein could anyone give your review please?

@kvendingoldo
Copy link

+1, also waiting for merge of this pr

@chaporgin
Copy link

@hiddeco, @onedr0p, @devstein could anyone give your review please?

@gemtreasure
Copy link

@kuzaxak , can u please resolve conflicts ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.