Skip to content

[POC] Secret Providers - #3124

Closed
aluzzardi wants to merge 1 commit into
dagger:mainfrom
aluzzardi:secrets-providers
Closed

aluzzardi wants to merge 1 commit into
dagger:mainfrom
aluzzardi:secrets-providers

Conversation

@aluzzardi

Copy link
Copy Markdown
Contributor

[NOTE: for discussion only, not meant to be merged]

This PR introduces the concept of "secret providers".

Example:

{
  core {
    image(ref: "alpine") {
      exec(input: {
        secretEnv: {name:"SECRET", id:"env://MY_SECRET"},
        args: ["printenv", "SECRET"]}
      ) {
        stdout
      }
    }
  }
}

In this basic example, env://MY_VARIABLE can be passed in place of any SecretID.

How does it work?

  1. Secrets are retrieved just in time, when buildkit requests them (through the secrets gRPC "callback")

  2. Cloak's secret provider turns around and issues a query against the API to resolve the secret, like so:

query {
  core {
    secrets {
      # in our example, this is going to be `env(name: "MY_SECRET")`
      plaintext: $PROTOCOL(name: $name)
    }
  }
}

e.g. For a given <protocol>://<key> SecretID, the query becomes core { secrets { <protocol>(name: <key>) }

Extensions

Let's imagine a hypothetical vault extension.

All the extension would have to do is extend Secrets with the new provider, like this:

extend type Secrets {
  vault(name: String!): String!
}

Then, automatically, vault://my_token will be a valid SecretID out of the box.

Cloak has a few built-in providers (env, file, ...) and extensions can add more on top.

Caveats

  • Caching needs to be disabled, otherwise all those secrets end up on disk
    • I have a potential solution in mind
  • The "interface" (extend type Secrets) is quick and dirty
    • We could do better, especially since cloak is "privileged" (e.g. don't need for the provider to be reachable through top-level Query

For instance, this might work:

# Provided by Core
interface SecretsProvider {
  protocol: String!
  plaintext(key: String!): String!
}

# An extension could look like this:
type VaultAlthoughTheTypeNameDoesntMatter implements SecretsProvider {
  protocol: String!
  plaintext(key: String!): String!
}

cloak can then scan the schema for types that implement SecretsProvider, query them for their protocol, and just-in-time resolve plaintext when a secret is needed.

Signed-off-by: Andrea Luzzardi <[email protected]>
This was referenced Sep 16, 2022
@github-actions

github-actions Bot commented Oct 1, 2022

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.

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

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

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Nov 21, 2022
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.

1 participant