Skip to content

feat: add dynamic secret API#4667

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

feat: add dynamic secret API#4667
dolanor merged 18 commits into
dagger:mainfrom
dolanor:dynamic-secrets

Conversation

@dolanor
Copy link
Copy Markdown
Contributor

@dolanor dolanor commented Feb 28, 2023

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
@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
Copy link
Copy Markdown
Contributor Author

dolanor commented Mar 13, 2023

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
Copy link
Copy Markdown
Contributor Author

dolanor commented Mar 13, 2023

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 <tanguy@dagger.io>
jlongtine and others added 10 commits March 13, 2023 22:48
Signed-off-by: Joel Longtine <joel@longtine.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
Copy link
Copy Markdown
Contributor

@vito vito left a comment

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 Outdated
Comment thread core/integration/secret_test.go Outdated
Comment thread core/schema/secret.graphqls Outdated
Comment thread secret/store.go Outdated
Comment thread secret/store.go Outdated
dolanor and others added 6 commits March 14, 2023 10:31
Co-authored-by: Alex Suraci <suraci.alex@gmail.com>
Signed-off-by: Tanguy ⧓ Herrmann <dolanorgit@evereska.org>
Co-authored-by: Alex Suraci <suraci.alex@gmail.com>
Signed-off-by: Tanguy ⧓ Herrmann <dolanorgit@evereska.org>
Co-authored-by: Alex Suraci <suraci.alex@gmail.com>
Signed-off-by: Tanguy ⧓ Herrmann <dolanorgit@evereska.org>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
The secret ID is already a name + digest

Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
(more idiomatic)

Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
@dolanor dolanor requested a review from vito March 14, 2023 10:16
Copy link
Copy Markdown
Contributor

@vito vito left a comment

Choose a reason for hiding this comment

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

Perfect! 🎉

Copy link
Copy Markdown
Contributor

@sipsma sipsma left a comment

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
@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