Skip to content

Proposal: dynamic secret via helpers - #4193

Closed
shykes wants to merge 1 commit into
dagger:mainfrom
shykes:pluggable-secrets
Closed

shykes wants to merge 1 commit into
dagger:mainfrom
shykes:pluggable-secrets

Conversation

@shykes

@shykes shykes commented Dec 14, 2022 •

Copy link
Copy Markdown
Contributor

This is a proposal for a new API that adds supports for #4426, by calling external helpers.

Highlights:

  • Secrets are looked up by an abstract key, for example "netlify_token"
  • Secret value is retrieved just-in-time when a pipeline needs it. Under the hood this is powered by buildkit "session attachables".
  • By default, secret value is retrieved by looking up the corresponding env variable
  • Custom secret retrieval logic can be injected by the operator, by adding an executable helper in the $PATH of the client machine.
  • This is similar to how Earthly supports secrets. Note this undocumented PR for the use of helpers.
  • Pre-existing File { secret } method is deprecated, because it is unsafe.

Relevant discussions:

@jlongtine

Copy link
Copy Markdown
Contributor

I think I understand the desire to create some separation between developer and operator, but I'm worried that this barrier will make the DX and OX worse. And I suspect our developers and operators will often be the same people.

Imagining writing pipelines using what you're describing sounds annoying and harder than I think it could/should be.

@shykes

shykes commented Dec 14, 2022

Copy link
Copy Markdown
Contributor Author

I think I understand the desire to create some separation between developer and operator, but I'm worried that this barrier will make the DX and OX worse. And I suspect our developers and operators will often be the same people.

Imagining writing pipelines using what you're describing sounds annoying and harder than I think it could/should be.

Can you write down an example of what you’re imagining?

My concern at the moment is with the OX. I give you a CI tool written with Dagger. You want to run it in Github Actions using their native secrets. How?

@jlongtine

Copy link
Copy Markdown
Contributor

Can you write down an example of what you’re imagining?

I'll spend some time today thinking about this and write up some examples.

My concern at the moment is with the OX. I give you a CI tool written with Dagger. You want to run it in Github Actions using their native secrets. How?

In this specific case, the only way to use GitHub Actions secrets is to set them as inputs to an Action or as an environment variable:

steps:
  - name: Hello world action
    with: # Set the secret as an input
      super_secret: ${{ secrets.SuperSecret }}
    env: # Or as an environment variable
      super_secret: ${{ secrets.SuperSecret }}

So, they must be explicitly defined in the GitHub Actions workflow yaml. There aren't any APIs you can call or commands that you can run that will get the secrets from the secrets store.

@shykes

shykes commented Dec 19, 2022

Copy link
Copy Markdown
Contributor Author

In this specific case, the only way to use GitHub Actions secrets is to set them as inputs to an Action or as an environment variable:

steps:
  - name: Hello world action
    with: # Set the secret as an input
      super_secret: ${{ secrets.SuperSecret }}
    env: # Or as an environment variable
      super_secret: ${{ secrets.SuperSecret }}

It would be better to not have to set the secret twice. But at least it's possible in the current model, so I didn't choose the best example.

What's your go-to example @jlongtine where the current OX are not enough?

For me it's any situation where the end user wants to configure their own secrets backend, without modifying the source code of the pipeline.

So, they must be explicitly defined in the GitHub Actions workflow yaml. There aren't any APIs you can call or commands that you can run that will get the secrets from the secrets store.

I think there is actually. But that's besides the point, see my point above.

@jlongtine

Copy link
Copy Markdown
Contributor

I agree the specifics here aren't really material to the general question around OX, but here's a bit of context around GitHub Secrets:

I think there is actually. But that's besides the point, see my point above.

The docs only show creating, listing, and "getting" secrets: https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28

"get" in this case being defined as:

Gets a single repository secret without revealing its encrypted value

@jlongtine

Copy link
Copy Markdown
Contributor

What's your go-to example @jlongtine where the current OX are not enough?

We've discussed using the Europa port as something to learn from. I don't see how I would implement that API. Being able to transform, clean up, and generate new secrets isn't possible (or at least very easy) with the design I'm seeing here.

I understand (to some degree) the desire to create some separation of concerns between developer and operator... but it feels like it's quite a large and sharp distinction right now.

As someone who has developed these sorts of pipelines before, I feel hindered (not helped) by this design.

@kpenfound

Copy link
Copy Markdown
Contributor

As someone who has developed these sorts of pipelines before, I feel hindered (not helped) by this design.

I agree. I think this pattern might make initial adoption of dagger easier, but I still think of the ideal end goal as being able to load secrets via extensions.

IMO, the "tip of the pyramid" users will not use Github/Gitlab/etc secrets, they'll use a proper secret store. That secret store will be standard for all pipelines no matter where they're executed, and therefore would most likely be codified in the pipeline

@rawkode

rawkode commented Dec 21, 2022

Copy link
Copy Markdown
Contributor

I think I understand the desire to create some separation between developer and operator, but I'm worried that this barrier will make the DX and OX worse. And I suspect our developers and operators will often be the same people.
Imagining writing pipelines using what you're describing sounds annoying and harder than I think it could/should be.

Can you write down an example of what you’re imagining?

My concern at the moment is with the OX. I give you a CI tool written with Dagger. You want to run it in Github Actions using their native secrets. How?

This used to be a huge problem, definitely; but with the recent SecretOps “movement” it’s much less so.

We have:

  • 1Password Connect
  • Cloud Secret Managers
  • Doppler
  • Infisical
  • Vault
  • Teller

Doppler can sync secrets to GitHub. Teller can read secrets from anywhere and make them available in the environment, OIDC on GH to Cloud Secret Managers.

I don’t think there’s an OX play here, secrets are a core part of the DX and zero-trust and shift left patterns mean developers are part of the security posture now more than ever.

@shykes

shykes commented Dec 21, 2022 •

Copy link
Copy Markdown
Contributor Author

I believe you guys are underestimating the importance of this question of separation of concerns. Secrets have both a DX and OX dimension no matter what we do. Designing the right line between them is very important and difficult- dismissing this will lead to a bad design. I could be wrong, but right now I am feeling confident that I’m not, so I’m going to ride that confidence for a while, and see where it takes us.

@rawkode let’s say you want to use 1password for everything on your machine (great choice 😁). You clone an open-source project which contains a bunch of dagger pipelines, some of which require secrets. There are many ways you could arrange for those secrets to come from 1password:

  • If it’s all in the client-side code (dynamic or static, doesn’t matter) then you’ll need to either modify the code to invoke the 1password tool or talk to its API, or modify it to use an env var so that you can then wrap the tool with 1password run and inject the env var
  • If we standardize on env vars being the only supported way to inject a secret, then you don’t need to modify the tool: just wrap with 1password run. However integrating with vault or anything even slightly dynamic now requires a wrapper too. Wrapper spaghetti is one of the patterns we were supposed to solve with composable pipelines…
  • Or you could “sync” to env vars or github secrets, and then either modify the tool to use those, or hope that they already do. This is a variation of the first two options, with a slightly different call path (no wrapper)

Basically all these options will suck for someone. Before going any further, let’s discuss that statement and how you feel about it 😁

@rawkode

rawkode commented Dec 21, 2022

Copy link
Copy Markdown
Contributor

Perhaps I don't understand the concern as much, I'm struggling to identify the root problem here.

Let's look at this.

This is my "OpEx" file, that no developer on my platform needs to care about or reason about.

It defines a SecretApi. Again, the developers don't need to know what this is - but the README should probably mention that you need to be authenticated with Doppler, but it could be anything.

We then create an interface that all jobs within the organisation need to adhere to, which defines the SecretsApi as the second parameter.

Now, developers can use getSecrets in any job and provide the parameters (project/config) to. get what they need for the jobs.

I could wrap this up and ship it as an NPM module if I wanted, but in my monorepo it's fine as it is.

How do you see this pipeline changing if Dagger provides your version of Secrets management?

@github-actions

github-actions Bot commented Jan 5, 2023

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@vito vito removed the kind/stale label Jan 5, 2023
@shykes shykes mentioned this pull request Jan 20, 2023
@shykes
shykes force-pushed the pluggable-secrets branch 2 times, most recently from 215fe62 to 221968b Compare January 26, 2023 18:58
@shykes
shykes force-pushed the pluggable-secrets branch from 221968b to b348ff7 Compare January 26, 2023 19:20
@shykes shykes changed the title API draft: pluggable secrets Proposal: dynamic secret handlers Jan 26, 2023
@shykes shykes changed the title Proposal: dynamic secret handlers Proposal: dynamic secret via helpers Jan 26, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@shykes

shykes commented Feb 18, 2023

Copy link
Copy Markdown
Contributor Author

After discussion with @samalba and @aluzzardi , there is a better design coming, so I'm withdrawing this proposal :)

@shykes shykes closed this Feb 18, 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.

5 participants