Giter Site home page Giter Site logo

thevilledev / vault-plugin-secrets-vercel Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 371 KB

Ephemeral @vercel authentication tokens with @hashicorp Vault

License: MIT License

Makefile 4.11% Go 95.89%
vault-plugins vault-secrets vercel ephemeral-credentials secrets hashicorp-vault

vault-plugin-secrets-vercel's Introduction

vault-plugin-secrets-vercel

Go Reference Go Report Card build codecov

What?

Vault Secrets Plugin for Vercel allows you to dynamically generate Vercel API tokens through Vault.

Why?

It is useful for more advanced CI/CD use cases where the common Vercel git integration is not being utilised. That is, Vercel might not even have access to your VCS and you will need to push instead of pull.

With this plugin, the CI/CD pipeline should:

  • Authenticate to Vault through a number of means. See hashicorp/vault-action docs for full list of available methods, such as:
    • AppRole
    • JWT OIDC
    • A pre-defined token
  • Call the plugin to generate a short-lived Vercel token. TTL and scope (Vercel team) for the token are user-configurable.
  • Run the actual deployment pipeline, such as Github Actions for Vercel
  • After token lifetime runs out, Vault revokes the token automatically.

Example

Here's a full example of a Github Actions pipeline utilising this plugin:

name: Vercel Preview Deployment
env:
  VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
  VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
  push:
    branches-ignore:
      - main

jobs:
  Deploy-Preview:
    runs-on: ubuntu-latest
    steps:
      - name: Import Secrets
        id: secrets
        uses: hashicorp/vault-action@65d7a12a8098b0aa7fcfdf22ad850c051f8b3ccb # v2.7.2
        with:
          url: ${{ secrets.VAULT_ADDR }}
          method: approle
          roleId: ${{ secrets.VAULT_ROLE_ID }}
          secretId: ${{ secrets.VAULT_SECRET_ID }}
          secrets: |
            vercel-secrets/token bearer_token | VERCEL_TOKEN

      - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

      - name: Install Vercel CLI
        run: npm install --global vercel@latest

      - name: Pull Vercel Environment Information
        run: vercel pull --yes --environment=preview --token=${{ steps.secrets.outputs.VERCEL_TOKEN }}

      - name: Build Project Artifacts
        run: vercel build --token=${{ steps.secrets.outputs.VERCEL_TOKEN }}

      - name: Deploy Project Artifacts to Vercel
        run: vercel deploy --prebuilt --token=${{ steps.secrets.outputs.VERCEL_TOKEN }}

Project scope

Currently this project is scoped for "Hobby" and "Pro" Vercel accounts. This means you can create tokens that:

  • Hobby: have full admin level access to your Vercel account.
  • Pro: have project-level access only. Applicable when token creation request is provided with the Token ID parameter.

Enterprise plan features, such as these, are currently scoped out:

  • Granular token-specific permissions

I don't have an Enterprise plan at hand. Contributions are welcome, of course!

Getting started

Get started by following the documentation:

Contributing

All contributions are welcome! Please see contribution guidelines.

vault-plugin-secrets-vercel's People

Contributors

dependabot[bot] avatar thevilledev avatar

Stargazers

 avatar

Watchers

 avatar

vault-plugin-secrets-vercel's Issues

Team scoped tokens

Pro plan allows users to create tokens scoped to specific teams. This allows the following:

  • Create an admin scope token for the plugin
  • Create team specific tokens with the plugin

See Vercel API endpoint docs for request/response format for creating team specific tokens.

Support for Vercel API v5

Currently auth token endpoint defaults to API v3. Latest API version is v5 which has backwards compatible response/request formats, but supports pagination. This plugin doesn't really need pagination as it always addresses tokens by ID, but in terms of risk of deprecation, switching to the latest version would be needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.