This is a standalone backend plugin for use with Hashicorp Vault. This plugin allows authentication to Vault using Cloud Access Management (CAM).
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.
This authentication model places Vault in the middle of a call between a client and TencentCloud's "GetCallerIdentity" method. Based on TencentCloud's response, it grants an access token based on pre-configured roles.
Please see documentation for the plugin
If you prefer to build the plugin from sources, clone the GitHub repository locally.
Build the auth method into a plugin using Go.
$ go build -o vault/plugins/vault-plugin-auth-tencentcloud ./cmd/vault-plugin-auth-tencentcloud/main.go
Copy the plugin binary into a location of your choice; this directory must be specified as
the plugin_directory
in the Vault configuration
file:
plugin_directory = "vault/plugins"
Start a Vault server with this configuration file:
$ vault server -config=vault/server.hcl
Once the server is started, register the plugin in the Vault server's plugin catalog:
$ SHA256=$(shasum -a 256 vault/plugins/vault-plugin-auth-tencentcloud | cut -d ' ' -f1)
$ vault plugin register -sha256=$SHA256 auth vault-plugin-auth-tencentcloud
$ vault plugin info auth vault-plugin-auth-tencentcloud
You can now enable the tencentCloud auth plugin:
$ vault auth enable -path=tencentcloud vault-plugin-auth-tencentcloud
Success! Enabled vault-plugin-auth-tencentcloud auth method at: tencentcloud/
If you wish to work on this plugin, you'll first need Go installed on your machine.
For local dev first make sure Go is properly installed, including setting up
a GOPATH. Next, clone this repository
into $GOPATH/src/github.com/hashicorp/vault-plugin-auth-tencentcloud
. 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="path/to/plugin/directory"
The plugin will automatically be added to the catalog with the name "vault-plugin-auth-tencentcloud". Run the following command to enable this new auth method as a plugin:
$ vault auth enable -path=tencentcloud vault-plugin-auth-tencentcloud
Success! Enabled vault-plugin-auth-tencentcloud auth method at: tencentcloud/
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.
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 TencentCloud account.
To run the acceptance tests, invoke make test-acc
:
$ export VAULT_ACC_TEST_SECRET_ID=YOU
$ export VAULT_ACC_TEST_SECRET_KEY=YOU SECRET KEY
$ export VAULT_ACC_TEST_TOKEN=YOU SECRET TOKEN (if you run as a CAM role, VAULT_ACC_TEST_TOKEN is required)
$ export CLIENT_CONFIG_TEST_SECRET_ID=CLIENT CONFIG SECRET ID
$ export CLIENT_CONFIG_TEST_SECRET_KEY=CLIENT CONFIG SECRET KEY
$ make test-acc
You can also specify a TESTARGS
variable to filter tests like so:
$ make test-acc TESTARGS='--run=TestConfig'
To run the integration tests, invoke make test
:
$ make test
You can also specify a TESTARGS
variable to filter tests like so:
$ make test TESTARGS='--run=TestConfig'