-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 Vault Transit Secret Engine #5147
Conversation
I am not too familiar with the use of nonce (beside the doc).
not sure what you mean
Basically all data is binary (it's passed as base64 strings into the vault api).
I know that the former can be achieved with the later, but when you have a single element, the weight of doing that with the batch api feels impractical (more instructions, no exception).
hmm. I have not thought about this. there is actually another very good use case: a jpa converter to store entity attributes as encrypted strings. |
Hi @vsevel , Re the nonce,
IMHO we should do the opposite, do not offer it at the API level, because as I said it is not something we should be expecting the users do correctly, the nonce generation has to be secure in its own way and since Quarkus offers the Vault integration, let Quarkus do the tricky things. Indeed, lets not do it at all :-), we can document that this engine targets the latest 0.63 version with the explanation why, and if ever needed the engine can drive the nonce generation, it is not really a user-level concern IMHO, even though it is probably a small utility only. You are right, the engine should not be trying to be too smart and start deciding whether to generate the nonce based on some heuristics :-) but if the users will need it then they will just ask nicely with a property and the engine will help.
I was asking about the purpose of
You are right, the shorter version can be simpler and indeed, having
One would inject the already
Sounds interesting :-). May be lets tune the 'core' interface and then discuss how to support it. May be we should have a concept of TypeConverter which would turn JPA/etc entities into String and back...and have encrypt/etc methods accepting Objects, etc |
I agree but not for the same reasons ;-)
actually 0.63 is way old (dec 2016). last version is 1.2.3 (sept 2019).
if just one user is asking for it, then I would rather get him to provide the value, rather than implementing the algorithm to do it correctly, and having to maintain this level of complexity in quarkus. people that are using nonce, have created their keys back in 2016, or before. so they do not need us to do it, they just need to be able to pass the nonce created with their algorithm.
it maps to the it is used for key derivation. see my example in #4888 (comment)
actually everything. I have seen situations where every sensitive data is encrypted in the db, including booleans, numbers, dates, blobs.
I have got to think more about that.
I have tried implementing an AttributeConverter, but the issue I found was that the attribute metadata was not available. I would have liked to write something like this:
but in the converter I do not get metadata on the |
for your https example, it looks more like a custom jackson serializer. but then again we do not get attribute metadata in the StdSerializer contract. all we could do is to create a serializer for a given type (eg |
@vsevel thanks, I got it about the Re +1 to tackling the encryption of the more complex objects in the next phase. |
Just to give you an idea on how I plan to use the new API: The General Data Protection Regulation (EU) requires that a user may request to delete it's personal data from a system. This is difficult in case of event sourced systems where the data is only stored in form of immutable events. The only way to achieve this, is to encrypt the sensitive parts of the message with a key that is uniquely used for that user. If the user requests to delete the data, only the private key is thrown away so no one can decrypt the data any longer. This key will be stored in Vault and the encrypt/decrypt functions will be called to encrypt/decrypt the sensitive data. Here is an example of such event: {
"event-id":"6fddc2e1-b64a-4df0-bb10-a2266a896c61",
"event-timestamp":"2019-04-25T08:17:43.476+02:00[Europe/Berlin]",
"entity-id-path":"PATIENT 386cec11-afdd-417b-b453-a140634e88bd",
"personal-data": {
"key-id":"PATIENT 386cec11-afdd-417b-b453-a140634e88bd",
"key-version":1,
"iv-version":2,
"data-type":"PatientPersonalData",
"content-type":"application/json; encoding=UTF-8; version=1",
"encrypted-data":"I03eadJjZ0S4lR/eSe65bxDtVRPXkethrnJLxYTPLUKvnRQshq6njrnFQIZMSDWBgQHJlCRh7UMBHejxuxfSq1dXWIo6bnHYOa6zMJITKDgn2eBUfIx8KrAQULQrH7BAL4DEGI3oPDVcs6Y9o1pdfok8hY1cfRLN5FuSHqoXNTb4uc9gdoHT/T0Lv+Rd6kRbb6Wmeuro/j2NoDG2EKKTk7R5BgGXBxt3ob6XLdW6T0xqZ8hvCAIMEH4ESlYe/QVOc/JcOyzA4CnKNzxxrGHRMuDIYww+2dfG/ZqXIWFbuh+x/6zFF21h/cQ="
},
"year-born":"1939"
} The "personal-data" is of type (EncryptedData.java) that has everything to decrypt and decode the data. The interfaces "EncryptedData.Encrypter" and "EncryptedData.Decrypter" will be implemented using the new Quarkus Vault Transit Secret Engine. I'm currently preparing a Quarkus example for my DDD / CQRS libraries implementing also the Vault Secret Engine feature: ddd-cqrs-4-java-example |
@michael-schnell thanks for your feedback. indeed I made some progress already. cc @sberyozkin |
@michael-schnell Your input is indeed very valuable, thank you :-) |
extensions/vault/runtime/src/main/java/io/quarkus/vault/transit/Plaintext.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
@vsevel The API is already looking good, thank you. We will complement with the more complex object support in the next phase and it will be super :-) Enjoy the weekend. |
I have made a thorough review on the so for |
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
@vsevel I'd not put the key version directly into the |
You can specify the key version only once for the full batch (it is not part of the batch item). I would not know what to do with a version specified in each Or introduce a wrapper object?
I thought about that, but then it lost the consistency with the other services encrypt, decrypt, ... What do you think about the last changes @sberyozkin ? |
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
@sberyozkin all comments addressed or tentatively answered. |
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Show resolved
Hide resolved
@vsevel thanks, it is nearly there IMHO and is looking neat. I'd just like to finalize the discussion about how the errors are addressed |
@vsevel re the key version, for signing we have a single key version for all the requests in the batch, which is fine. But for encryption - it is per request specific in the batch. We should have the same mechanism at the API level IMHO. The fact that Vault expects it in the different places in the request for encrypt vs sign is not important IMHO |
@sberyozkin are you suggesting to not support key version per request, but instead at the whole batch level? |
@sberyozkin by the way, I changed |
@vsevel |
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
no problem. I hope you had a good trip.
yes. this has been handled.
when is due 1.1? I though it was 6 months after 1.0...
you perfectly summarized my state of mind ;)
if you feel strong about changing it back, I do not have a problem. that should not be too long. I have just pushed the last changes. waiting for the CI to pass. |
hello @michael-schnell |
@vsevel thanks; yes, it all looks good to me now. |
Please don't merge until @gsmet has had a look |
As the feature was now removed from 1.1.0 - Will there a snapshot JAR be available instead? (Like on https://oss.sonatype.org/content/repositories/snapshots/ ) - Would be good to allow already using it via an official Maven repo. |
hello all, @michael-schnell I suppose you can clone my repo and build it locally. the only build I know of is from master. @gsmet @sberyozkin I know it is a busy time of the year, but can we start considering it for 1.2? what is the next step? who could review the PR? thanks |
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.
@vsevel I added a couple of small comments on the doc. Otherwise, it just needs a rebase and we can merge it for the next version.
Thanks!
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/VaultTransitSecretEngine.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/TransitKeyConfig.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/TransitKeyConfig.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/TransitKeyConfig.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/TransitKeyConfig.java
Outdated
Show resolved
Hide resolved
extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultRuntimeConfig.java
Show resolved
Hide resolved
Shouldn't the |
here is an update on the PR based on the latest comments: @gastaldi the PR was rebased. I will do a final squash before the merge. @lordofthejars suggested to update the existing guide, or create a new one. Initially I thought the javadoc would be enough, at least for specialists. but I recognize that some additional documentation would help a lot with adoption. there is a lot of material already in the existing guide, which focuses on the kv secret engine and vault config source. for the sake of simplicity I had already decided to leave apart other topics that I thought were worth documenting (k8s authentication and dynamic db credentials). so I would rather create a separate guide for the transit engine. but I am open for suggestions. do we want to have just one guide per extension, or one guide per topic? @gsmet I applied all your recommendations with respect to documentation. I did a full review and found also some other cases that were worth correcting also: 7ae12d5 however, I was not able to get the out of curiosity, is there any javadoc documentation for apis (e.g. If I start working on the guide, when should that be ready? |
@vsevel as we add more and more support to Vault we are going to have the problem you mention here with documentation. So I think that creates a new document might be the best approach and when we have the full support of Vault, then we could rearrange all the Vault part. |
@vsevel Can you please do some basic initial doc about the transit engine so that we can get this PR for 1.2.0 ? I guess by the end of this week would be ideal ? thanks |
Hi Vincent @vsevel How is it going, we have just a couple of days before 1.2.0 CR1. |
I squashed everything and rebased. If everything is green tomorrow morning, I'll merge it. |
@gsmet thanks :-) |
@sberyozkin @gsmet thanks for merging. last week I was too busy in the evening, and could not find during the weekend. I saw you created #6636. you can assign it to me. I will create a first draft this week. |
Fixes #4888.
From #4888:
The transit engine provides encryption as a service for a client application. Instead of storing your encryption key securely, and retrieve it from your application to apply the encrypt/decrypt algorithm locally, you delegate this to vault: You just ask vault to create a key and associate it with a name that you pass, then use the encrypt and decrypt services from vault passing just the key name. That way you do not have to embed the encryption algorithms in your app, and the encryption key never leaves the vault.
Encrypting/Decrypting sensitive data that need to be stored in a primary store is a very common use case. This would bring value to quarkus to make that feature available and usable with ease.