GithubHelp home page GithubHelp logo

isabella232 / vault-plugin-auth-gcp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashicorp/vault-plugin-auth-gcp

0.0 0.0 0.0 10.6 MB

GCP Authentication Plugin for Vault

License: Mozilla Public License 2.0

Makefile 1.17% Go 96.04% Shell 2.79%

vault-plugin-auth-gcp's Introduction

Vault Plugin: Google Cloud Platform Auth Backend

This is a standalone backend plugin for use with HashiCorp Vault. This plugin allows for various GCP entities to authenticate with Vault. This is currently included in Vault distributions.

Currently, this plugin supports login for:

  • IAM service accounts
  • GCE Instances

Please note: We take Vault's security and our users' trust very seriously. If you believe you have found a security issue in Vault, please responsibly disclose by contacting us at [email protected].

Quick Links

Getting Started

This is a Vault plugin and is meant to work with Vault. This guide assumes you have already installed Vault and have a basic understanding of how Vault works.

Otherwise, first read this guide on how to get started with Vault.

To learn specifically about how plugins work, see documentation on Vault plugins.

Usage

Please see documentation for the plugin on the Vault website.

This plugin is currently built into Vault and by default is accessed at auth/gcp. To enable this in a running Vault server:

$ vault auth enable gcp
Success! Enabled gcp auth method at: gcp/

To see all the supported paths, see the GCP auth backend docs.

Developing

Please note that local development is only required if you plan to contribute or compile this plugin yourself. This plugin is automatically bundled in Vault installations and is available by default. You do not need to compile it yourself unless you intend to modify it.

If you wish to work on this plugin, you'll first need Go installed on your machine (version 1.10+ is required).

For local dev first make sure Go is properly installed, including setting up a GOPATH. Next, clone this repository into your GOPATH:

$ mkdir -p $GOPATH/src/github.com/hashicorp
$ git clone https://github.com/hashicorp/vault-plugin-auth-gcp $GOPATH/src/github.com/hashicorp/
$ cd vault-plugin-auth-gcp

You can then download any required build tools by bootstrapping your environment:

$ make bootstrap

To compile a development version of this plugin, run make or make dev. This will put the plugin binary in the bin and $GOPATH/bin folders. dev mode will only generate the binary for your platform and is faster:

$ make
$ make dev

For local development, use Vault's "dev" mode for fast setup:

$ vault server -dev -dev-plugin-dir="$(pwd)/bin"

The plugin will automatically be added to the catalog with the name "vault-plugin-auth-gcp". Run the following command to enable this new auth method as a plugin:

$ vault auth enable -plugin-name="vault-plugin-auth-gcp" -path="gcp" plugin
Success! Enabled vault-plugin-auth-gcp plugin at: gcp/

Tests

This plugin has comprehensive acceptance tests covering most of the features of this auth backend.

If you are developing this plugin and want to verify it is still functioning (and you haven't broken anything else), we recommend running the acceptance tests.

Acceptance tests typically require other environment variables to be set for things such as access keys. The test itself should error early and tell you what to set, so it is not documented here.

Warning: The acceptance tests create/destroy/modify real resources, which may incur real costs in some cases. In the presence of a bug, it is technically possible that broken backends could leave dangling data behind. Therefore, please run the acceptance tests at your own risk. At the very least, we recommend running them in their own private account for whatever backend you're testing.

To run the acceptance tests, you will need a GCP IAM service account with the permissions listed below. The following steps assume you have gcloud installed.

  1. Save the name of your project as an environment variable for reference:

    $ export GOOGLE_CLOUD_PROJECT=my-project # replace with your project ID
    
  2. Enable the IAM service on the project:

    $ gcloud services enable --project "${GOOGLE_CLOUD_PROJECT}" \
        cloudresourcemanager.googleapis.com \
        iam.googleapis.com
    
  3. Create the service account:

    $ gcloud iam service-accounts create vault-tester \
        --display-name vault-tester \
        --project "${GOOGLE_CLOUD_PROJECT}"
    
  4. Grant project.viewer and serviceaccount.admin permissions:

    $ gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
        --member "serviceAccount:vault-tester@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com" \
        --role "roles/viewer"
    
    $ gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
        --member "serviceAccount:vault-tester@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com" \
        --role "roles/iam.serviceAccountKeyAdmin"
    
    $ gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
        --member "serviceAccount:vault-tester@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com" \
        --role "roles/iam.serviceAccountTokenCreator"
    
  5. Download the service account key file to local disk:

    $ gcloud iam service-accounts keys create vault-tester.json \
        --iam-account "vault-tester@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
    
  6. Export the credentials to an environment variable:

    $ export GOOGLE_CREDENTIALS="$(cat vault-tester.json)"
    

To run the acceptance tests, invoke make test:

$ make test

You can also specify a TESTARGS variable to filter tests like so:

$ make test TESTARGS='--run=TestConfig'

vault-plugin-auth-gcp's People

Contributors

austingebauer avatar briankassouf avatar broamski avatar calvn avatar emilymye avatar jefferai avatar kalafut avatar madalynrose avatar malnick avatar mitchellbot avatar noelledaley avatar pcman312 avatar sethvargo avatar sgmiller avatar tomhjp avatar tvoran avatar tyrannosaurus-becks avatar vishalnayak avatar vvakame avatar

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.