Code Monkey home page Code Monkey logo

vault-plugin-secrets-alicloud's Introduction

Vault Plugin: AliCloud Platform Secrets Backend

This is a backend plugin to be used with Hashicorp Vault. This plugin generates unique, ephemeral API keys and STS credentials.

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

Quick Links

Usage

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.

If you are using Vault 11.0.1 or above, this plugin is packaged with Vault and by default can be enabled by running:

$ vault secrets enable alicloud

Success! Enabled the alicloud secrets engine at: alicloud/

If you are testing this plugin in an earlier version of Vault or want to develop, see the next section.

Developing

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

Make sure Go is properly installed, including setting up a GOPATH.

Get Plugin

Clone this repository:


mkdir $GOPATH/src/github.com/hashicorp/vault-plugin-secrets-alicloud`
cd $GOPATH/src/github.com/hashicorp/
git clone https://github.com/hashicorp/vault-plugin-secrets-alicloud.git

(or use go get github.com/hashicorp/vault-plugin-secrets-alicloud ).

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

Install Plugin in Vault

Put the plugin binary into a location of your choice. This directory will be specified as the plugin_directory in the Vault config used to start the server.

plugin_directory = "path/to/plugin/directory"

Start a Vault server with this config file:

$ vault server -config=path/to/config.json ...

Once the server is started, register the plugin in the Vault server's plugin catalog:

$ vault plugin register \
        -sha256="$(shasum -a 256 path/to/plugin/directory/vault-plugin-secrets-alicloud | cut -d " " -f1)" \
        -command="vault-plugin-secrets-alicloud" \
        secret \
        alicloudsecrets

Any name can be substituted for the plugin name "alicloudsecrets". This name will be referenced in the next step, where we enable the secrets plugin backend using the AliCloud secrets plugin:

$ vault secrets enable --plugin-name='alicloudsecrets' --path="alicloud" plugin

Tests

This plugin has both integration tests and acceptance tests.

The integration tests fire API calls at a local test server that returns expected responses rather than firing real API calls. They are executed by the following:

$ make test

The acceptance tests fire real API calls, and are located in acceptance_test.go. These should be run once as a final step before placing a PR. The following environment variables will need to be set for the acceptance tests to run:

  • VAULT_ACC=1
  • VAULT_SECRETS_ACC_TEST_ROLE_ARN
  • VAULT_SECRETS_ACC_TEST_ACCESS_KEY_ID
  • VAULT_SECRETS_ACC_TEST_SECRET_KEY

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, after exporting the necessary environment variables, execute the following from the home directory:

$ make testacc

Or to execute only the acceptance tests:

./scripts/run_acceptance.sh

Other Docs

See up-to-date docs and general API docs.

vault-plugin-secrets-alicloud's People

Contributors

austingebauer avatar averche avatar benashz avatar calvn avatar dependabot[bot] avatar fairclothjm avatar hashicorp-copywrite[bot] avatar hashicorp-tsccr[bot] avatar hc-github-team-secure-vault-ecosystem avatar jefferai avatar malnick avatar mdeggies avatar mikeadityas avatar renovate-bot avatar robmonte avatar thyton avatar tomhjp avatar tyrannosaurus-becks avatar vinay-gopalan avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vault-plugin-secrets-alicloud's Issues

use vpc endpoint

When the service has access to the AliCloud VPC network, it should prioritize getting STS credentials through the VPC network rather than accessing the sts endpoints through the public network.

Therefore, I think we should provide an opportunity to allow users to connect to VPC endpoints instead of brute-force hard-coding a public network endpoint.

plugin will never fallback to instance metadata

The plugin always requires that an access_key and secret_key be set due to this line:
https://github.com/hashicorp/vault-plugin-secrets-alicloud/blob/master/path_creds.go#L48

From reading the code, I believe credentials set in the environment would be used before the configured values, but I haven't tested this. Where this completely falls over is when attempting to use the recommended method of falling back to the credentials provided by an AliCloud ECS instance role.

secret is missing inline_policies internal data

Hello there,

I followed docs and wrote the policy-based like doc, and create a lease:

$ vault read alicloud/creds/policy-based
Key                Value
---                -----
lease_id           alicloud/creds/policy-based/HhFLFROWDeftRtwTJwtw5XuJ
lease_duration     768h
lease_renewable    true
access_key         LTAI4FtEqaL5JTy6hFvSdkAH
secret_key         pPkGJMcxWV4I4JElfd19bt6rKtv6sx

$ vault read alicloud/role/policy-based
Key                Value
---                -----
inline_policies    [map[hash:8d5db9715fa1fd38c1609a65bf5a453d policy_document:map[Statement:[map[Action:[ram:CreateAccessKey ram:DeleteAccessKey ram:CreatePolicy ram:DeletePolicy ram:AttachPolicyToUser ram:DetachPolicyFromUser ram:CreateUser ram:DeleteUser sts:AssumeRole] Effect:Allow Resource:*]] Version:1]]]
max_ttl            0s
remote_policies    <nil>
role_arn           n/a
ttl                0s

When I revoked lease, the access key has been deleted successfully, but policies and user remained. Vault server showed error log:

2020-03-16T17:23:36.787+0800 [ERROR] expiration: failed to revoke lease: lease_id=alicloud/creds/policy-based/HhFLFROWDeftRtwTJwtw5XuJ error="failed to revoke entry: resp: (*logical.Response)(nil) err: secret is missing inline_policies internal data"

Which point to code line 141 in path_secrects.go:

// Inline policies are currently stored as remote policies, because they have been
		// instantiated remotely and we need their name and type to now detach and delete them.
		inlinePolicies, err := getRemotePolicies(req.Secret.InternalData, "inline_policies")
		if err != nil {
			// This shouldn't be part of the multierror because if it returns empty inline policies,
			// then we won't go through the inlinePolicies loop and we'll think we're successful
			// when we actually didn't delete the inlinePolicies we need to.
			return nil, err
		}

Have I done something wrong? Thanks.

BUG: wrong argument parsing when only one remote_policies is provided

vault write alicloud/role/direct-mail remote_policies=name:AliyunDirectMailFullAccess,type:System
Error writing data to alicloud/role/direct-mail: Error making API request.

URL: PUT https://rubick.dev.wwrkr.cn:8200/v1/alicloud/role/direct-mail
Code: 500. Errors:

* 1 error occurred:
	* policy type is required in name:AliyunDirectMailFullAccess

However, the following command succeeded:

vault write alicloud/role/direct-mail remote_policies='name:AliyunDirectMailFullAccess,type:System' remote_policies='name:AliyunDirectMailReadOnlyAccess,type:System'
Success! Data written to: alicloud/role/direct-mail

I believe vault treats comma-separated string as a list. Take this line of code for example, in the first case, strPolicies equals to ["name:AliyunDirectMailFullAccess", "type:System"], which is not desired.

My Vault client version is:

Vault v1.1.3 ('9bc820f700f83a7c4bcab54c5323735a581b34eb')

Alicloud secret ak/sk config not work in alicloud/config

we are use alicloud kms to auto unseal.so,we are have some ak/sk env in vault starup script.

but,if i use alicloud secret engine. alicloud/config ak/sk config not working.

I review some code for that plugin:

that define first find env config.that not great,in secret engine case,not need read env config,that ak/sk will defined in alicloud/config
vault-plugin-secrets-alicloud/clients/creds.go

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.