Resolve 1Password Secret Reference via the 1Password SDK#69
Draft
JillRegan wants to merge 6 commits intovercel:mainfrom
Draft
Resolve 1Password Secret Reference via the 1Password SDK#69JillRegan wants to merge 6 commits intovercel:mainfrom
JillRegan wants to merge 6 commits intovercel:mainfrom
Conversation
|
@JillRegan is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds 1Password support to the Sandbox SDK and CLI. You pass 1Password secret references (
op://vault/item/field) inintegrations.onePassword.secretswhen creating or getting a sandbox. The SDK resolves them client-side with the 1Password SDK (using a service account token or the desktop app) and injects the resolved values into the environment for every runCommand call. The CLI’s exec command also supports op:// refs in --env, so you can run commands with secrets resolved from 1Password without putting them in your shell environment.Changes
SDK
integrations.onePassword.secretsoption onSandbox.create()andSandbox.get(): a map of env var names toop:// refs.runCommand.CLI
--envaccepts values that are op:// refs. They are resolved before the command runs (-env API_KEY=op://Vault/Item/field).Example
examples/onepassword-secrets: creates a sandbox with a secret from 1Password and runs a command that uses it. This is a minimal demo to show the flow. We're open to feedback from Vercel's team on example structure or additional examples.Documentation updates
How it works
integrations: { onePassword: { secrets: { MY_VAR: "op://Vault/Item/field" } } }to Sandbox.create() or Sandbox.get().OP_SERVICE_ACCOUNT_TOKEN(orOP_ACCOUNTfor desktop) to call the 1Password SDK and resolve each ref.runCommand().How to test
Prerequisites
op://My Vault/My Item/credential).OP_ACCOUNT). See https://developer.1password.com/docs/sdks/ for more info.Run the
onepassword-secretsexampleFrom repo root run
pnpm buildthenexamples/onepassword-secretsandpnpm installCreate .env.local with:
OP_SERVICE_ACCOUNT_TOKEN=
OP_REF=op://Your Vault/Your Item/field name
Run:
pnpm startYou should see output indicating the secret is set (e.g. MY_SECRET is set: yes and a non-zero length). If you see length 0, check OP_REF and token/vault access.
CLI exec with op refs
Create a sandbox ensure the 1Password token is available (
export OP_SERVICE_ACCOUNT_TOKEN=... or run with --env-file .env.local). Run:sandbox exec <sandbox-id> --env API_KEY=op://Vault/Item/field -- echo '$API_KEY'