GithubHelp home page GithubHelp logo

mongey / vault-plugin-auth-github-actions Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 3.0 40 KB

A vault plugin to authenticate GitHub actions

License: MIT License

Makefile 21.06% Shell 7.19% Go 71.75%
vault-plugins vault-plugin github-actions vault

vault-plugin-auth-github-actions's Introduction

vault-plugin-auth-github-actions

Authenticate with vault from your github actions.

Setup

  1. Download and decompress the latest plugin binary from the Releases tab on GitHub. Alternatively you can compile the plugin from source.

  2. Move the compiled plugin into Vault's configured plugin_directory:

$ mv vault-plugin-auth-github-actions /etc/vault/plugins/vault-plugin-auth-github-actions
  1. Calculate the SHA256 of the plugin and register it in Vault's plugin catalog. If you are downloading the pre-compiled binary, it is highly recommended that you use the published checksums to verify integrity.
$ export SHA256=$(shasum -a 256 "/etc/vault/plugins/vault-plugin-auth-github-actions" | cut -d' ' -f1)

$ vault write sys/plugins/catalog/auth/github-actions-auth-plugin \
    sha_256="${SHA256}" \
    command="vault-plugin-auth-github-actions"
  1. Mount the auth method:
$ vault auth enable \
    -path="github-actions" \
    -plugin-name="auth-github-actions" plugin
  1. Configure the role your repository should assume
$ vault write auth/github-actions/repositories/Mongey/vault-plugin-auth-github-actions policies=admin
  1. Point your github action to import your secrets from Vault
      - name: Import Secrets
        id: secrets
        uses: hashicorp/[email protected]
        with:
          url: https://my-vault-server.org:8200
          method: github-actions
          secrets: secret/data/ci npmToken | NPM_TOKEN
          authPayload: |
          '{
            "token": "${{ secrets.GITHUB_TOKEN }}",
            "run_id": "${{ github.run_id }}",
            "run_number": "${{ github.run_number }}",
            "owner": "${{ github.repository_owner }}",
            "repository": "${{ github.repository }}"
          }'
      - name: Print
        env:
          MY_VAR: Hello
          FOO: ${{ steps.secrets.outputs.NPM_TOKEN }}
        run: |
          echo $MY_VAR $FOO $NPM_TOKEN

Assign a default policy to all repositories in your organization

$ vault write auth/github-actions/organizations/Mongey policies=admin

Configuration

To configure it, use the /config endpoint with the following arguments:

  • base_url (string, optional) - For GitHub Enterprise or other API-compatible servers, the base URL to access the server.

For example:

vault write auth/github-actions/config base_url=https://enterprise.github.com/

vault-plugin-auth-github-actions's People

Contributors

mongey avatar russparsloe avatar steveteuber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vault-plugin-auth-github-actions's Issues

Add LICENSE

Hello. I think it would be a good idea to add an open source software license to this repo to explain how the code can be used. Vault itself uses MPL2 although you should choose the model you feel would fit best. Thanks!

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.