GCP Authentication Plugin for Vault
Switch branches/tags
Nothing to show
Clone or download
emilymye Merge pull request #55 from emilymye/gce_aliases
Group aliases, project_id --> optional bound_projects, no caching GCP API clients
Latest commit 0a3edf0 Nov 15, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
plugin fixes, use google cred parsing from google libraries Nov 9, 2018
scripts add local dev script Nov 7, 2018
vendor vendor update Nov 9, 2018
.gitignore gitignore Jul 15, 2017
Gopkg.lock vendor update Nov 9, 2018
Gopkg.toml bump deps Aug 16, 2018
LICENSE Fix license cutoff Sep 28, 2018
Makefile Run tests in parallel Jul 9, 2018
README.md Require Go v0.10+ Jul 10, 2018
main.go Ignore os.Args[0] when parsing flags (#9) Sep 7, 2017

README.md

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 security@hashicorp.com.

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 project.viewer and serviceaccount.admin permission. You can generate one from the Google Cloud Console. Save this file locally and export its contents as an environment variable:

$ export GOOGLE_CREDENTIALS="$(cat my-credentials.sh)"

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'