Skip to content

feat: add dynamic secret API - #4667

Merged
dolanor merged 18 commits into
dagger:mainfrom
dolanor:dynamic-secrets
Mar 15, 2023
Merged

dolanor merged 18 commits into
dagger:mainfrom
dolanor:dynamic-secrets

Conversation

@dolanor

@dolanor dolanor commented Feb 28, 2023 •

Copy link
Copy Markdown
Contributor

This PR adds a top level query setSecret(name: String!, plaintext: String!): Secret! that will associate a user defined secret name to a plaintext value.

Points to figure out

file.secret() deprecation

At the same time, we deprecate file.secret() as it leaks secrets in the cache. It is not a breaking change, yet. But as it is insecure, I thought of actually breaking the file.secret() implementation (especially the one bringing the secret in) by always returning an error. We wouldn't want people to use it nonetheless and have important secrets leaked.

=> viewed with @jlongtine : we keep backwards compatibility, no breaking change

secret id content

The only information going into the container information would be the secret id which is a base64 of the name of the secret and the sha256(plaintext). It should bust the cache if we change the plaintext. I think this is the behavior that we want. But it would be less secure than if we used a hash only derived from the secret name. In that case, nobody would know if the secret plaintext has been changed, and the cached version would be used. The user would have to bust their cache by themselves.

I'm open to discussion/experience sharing about this.

@dolanor
dolanor requested a review from jlongtine February 28, 2023 14:31
@dolanor dolanor linked an issue Feb 28, 2023 that may be closed by this pull request
@dolanor
dolanor marked this pull request as draft February 28, 2023 14:36
@dolanor
dolanor force-pushed the dynamic-secrets branch 2 times, most recently from 2e7b00f to 1de281b Compare February 28, 2023 14:40
Comment thread secret/store.go Resolved
@dolanor
dolanor force-pushed the dynamic-secrets branch 8 times, most recently from b5f16c1 to 647a557 Compare March 7, 2023 00:20
@dolanor
dolanor force-pushed the dynamic-secrets branch 2 times, most recently from 9972261 to 944e2ec Compare March 13, 2023 14:35
@dolanor
dolanor marked this pull request as ready for review March 13, 2023 14:47
@dolanor

dolanor commented Mar 13, 2023

Copy link
Copy Markdown
Contributor Author

The current implementation of this secret use a new encoding instead of reusing the payload encoding. It works and passes tests.
I tried to homogenize everything by reusing the "normal" payload encoding, but some side-effects makes the file secret tests fail and I lost enough time on it and I need some other eyes to check that: dolanor#206 (It's on my fork to be able to merge on top of this branch).
But if you could review this one, at least we would have the functionality and could test other scenarios as well.

@dolanor

dolanor commented Mar 13, 2023

Copy link
Copy Markdown
Contributor Author

Finally found the problem, will update this one. Hopefully tonight.

@dolanor
dolanor force-pushed the dynamic-secrets branch 4 times, most recently from ee910cd to 061635b Compare March 13, 2023 21:11
@dolanor dolanor changed the title feat!: add dynamic secret API feat: add dynamic secret API Mar 13, 2023
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
jlongtine and others added 10 commits March 13, 2023 22:48
Signed-off-by: Joel Longtine <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good, mostly nitpicks! I like the idea of storing a digest in the SecretID to keep them deterministic. 👍

Comment thread core/integration/secret_test.go Resolved
Comment thread core/integration/secret_test.go Resolved
Comment thread core/schema/secret.graphqls Resolved
Comment thread secret/store.go Resolved
Comment thread secret/store.go Resolved
dolanor and others added 6 commits March 14, 2023 10:31
Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
The secret ID is already a name + digest

Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
(more idiomatic)

Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
@dolanor
dolanor requested a review from vito March 14, 2023 10:16

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perfect! 🎉

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for the late unhelpful review, but looks great, happy we finally get this!

Comment thread engine/remotecache/mountsync.go Resolved
@dolanor
dolanor merged commit 475f199 into dagger:main Mar 15, 2023
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.

Dynamic secrets

5 participants