Code Monkey home page Code Monkey logo

hashicorp / vault-service-broker Goto Github PK

View Code? Open in Web Editor NEW
84.0 34.0 38.0 37.18 MB

The official HashiCorp Vault broker integration to the Open Service Broker API. This service broker provides support for secure secret storage and encryption-as-a-service to HashiCorp Vault.

Home Page: https://www.vaultproject.io/

License: Mozilla Public License 2.0

Makefile 3.18% Go 96.02% Dockerfile 0.79%
golang vault service-broker open-service-broker open-service-broker-api kubernetes openshift cloud-foundry

vault-service-broker's Introduction

HashiCorp Vault Service Broker

This repository provides an implementation of the open service broker API for HashiCorp's Vault. The service broker connects to an existing Vault cluster and can be used by multiple tenants within Cloud Foundry.

Getting Started

The HashiCorp Vault Service Broker does not run a Vault server for you. There is an assumption that the Vault cluster is already setup and configured. This Vault server does not need to be running under Cloud Foundry, OpenShift, Kubernetes, etc, but it must be accessible from within those environments or wherever the broker is deployed.

These getting started instructions assume the Vault server's address and token are specified as the following environment variables:

$ export VAULT_ADDR="https://vault.company.internal/"
$ export VAULT_TOKEN="abcdef-134255-..."

Additionally the broker is configured to use basic authentication. The variables will be:

$ export AUTH_USERNAME="vault"
$ export AUTH_PASSWORD="broker-secret-password"

Creating a Dev Environment

Note: This section takes a good amount of time (likely, an hour or more) due to downloading a 16gb ISO and VirtualBox taking a while to create an environment.

  1. Register for an account at https://pivotal.io.
  2. Install the cf CLI: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html.
  3. Ensure you have VirtualBox installed.
  4. Ensure you have ~30gb of disk storage available in your local environment for the VirtualBox ISO and the env cf will create.
  5. Go through installation and configuration of cf through the page on the cf login step here: https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry-dev/introduction. Ignore the sample app steps regarding a Spring app.
  6. Note that when logging in following the example, the username is literally user and the password is literally pass, not the username and password you created during registration.
  7. Run Vault locally: $ vault server -dev. Use the Vault token returned as the VAULT_TOKEN value exported above.
  8. Make Vault reachable to your VM using ngrok (https://ngrok.com/): $ ngrok http 8200. Use the http URL shown as the VAULT_ADDR value exported above (example value: "http://4d4053a3.ngrok.io").

Deploying the Broker

The first step is deploying the broker. This broker can run anywhere including Cloud Foundry, Kubernetes, Heroku, HashiCorp Nomad, or your local laptop. This example shows running the broker under Cloud Foundry.

First, create a space in which to run the broker:

$ cf create-space vault-broker

Switch over to that space:

$ cf target -s vault-broker

Deploy the vault-broker by cloning this repository:

$ git clone https://github.com/hashicorp/vault-service-broker
$ cd vault-service-broker

And push to Cloud Foundry:

$ cf push --random-route --no-start
  • The --random-route flag is optional, but it allows us to easily run more than one Vault broker if needed, instead of relying on "predictable names".

  • The --no-start flag is important because we have not supplied the required environment variables to our application yet. It will fail to start now.

To configure the broker, provide the following environment variables:

$ cf set-env vault-broker VAULT_ADDR "$VAULT_ADDR"
$ cf set-env vault-broker VAULT_TOKEN "$VAULT_TOKEN"
$ cf set-env vault-broker SECURITY_USER_NAME "$AUTH_USERNAME"
$ cf set-env vault-broker SECURITY_USER_PASSWORD "$AUTH_PASSWORD"
$ cf restage vault-broker

Now that it's configured, start the broker:

$ cf start vault-broker

To verify the HashiCorp Vault broker is running, execute:

$ cf apps

name           requested state   instances   memory   disk   urls
vault-broker   started           1/1         256M     512M   vault-broker-torpedolike-reexploration.local.pcfdev.io

Grab the URL and save it in a variable or copy it to your clipboard - we will need this later.

export BROKER_URL=$(cf app vault-broker | grep -E -w 'urls:|routes:' | awk '{print $2}')

NOTE: Different versions of Cloud Foundry display this information differently. If the result of the pipeline above is empty, try running cf app vault-broker and look at the output. It is possible that the key has changed again and you'll need to grep for that instead of urls: or routes:.

Again, there is no requirement that our broker run under Cloud Foundry - this could be a URL pointing to any service that hosts the broker, which is just a Golang HTTP server.

To verify the broker is working as expected, query its catalog:

$ curl -s "${AUTH_USERNAME}:${AUTH_PASSWORD}@${BROKER_URL}/v2/catalog"

The result will be JSON that includes the list of plans for the broker:

{
  "services": [
    {
      "id": "0654695e-0760-a1d4-1cad-5dd87b75ed99",
      "name": "hashicorp-vault",
      "description": "HashiCorp Vault Service Broker",
      "bindable": true,
      "tags": [""],
      "plan_updateable": false,
      "plans": [
        {
          "id": "0654695e-0760-a1d4-1cad-5dd87b75ed99.shared",
          "name": "shared",
          "description": "Secure access to Vault's storage and transit backends",
          "free": true
        }
      ]
    }
  ]
}

The HashiCorp Vault Service Broker is now running under Cloud Foundry and ready to receive requests.

Register the Vault Broker

Before it can bind to services, the broker must be registered with Cloud Foundry. Remember that there is no requirement that the broker be running under Cloud Foundry, so we will need to provide the broker registration service the BROKER_URL from above.

To register the broker, an application developer first creates a new space where they will request the broker access:

$ cf create-space example
$ cf target -s example

Next, register the broker in this space:

$ cf create-service-broker vault-broker "${AUTH_USERNAME}" "${AUTH_PASSWORD}" "https://${BROKER_URL}" --space-scoped

Note: This will allow developers in the current space to access the broker. If other developers in another space want to access it, they will need to create their own instance. This is a good starting workflow, but more complex setups should investigate allowing access to plans globally or per-organization.

Note: Here we are scoping the broker to a space. In larger installations, it may be desirable to run a centralized instance of the broker that is accessible to all spaces in the organization. For more information on this deployment pattern, please see the notes in the standard broker section.

To verify the command worked, query the marketplace. You should see the Vault broker with a plan of 'default' in addition to any other services you may have access to:

$ cf marketplace
service           plans             description
hashicorp-vault   shared            HashiCorp Vault Service Broker
# ...

Create a service instance and bind an app

After registering the service in the marketplace, it is now possible to create a service instance and bind to it.

First, create a service instance using the default plan. For this example we will name the service instance 'my-vault':

$ cf create-service hashicorp-vault shared my-vault

With a service instance in place, you are ready to bind an app. Suppose we have an app called 'my-app'. An example of my-app can be found in the example directory along with instructions on how to deploy it.

$ cf bind-service my-app my-vault

You will need to restage the app to pick up the environment changes.

$ cf restage my-app

When the app starts back up, its VCAP_SERVICES environment variable will contain an entry for the my-vault service. You can confirm this by checking the app's environment variables:

$ cf env my-app

The VCAP_SERVICES environment variable will have a section similar to the following:

{
	"hashicorp-vault": [{
		"credentials": {
			"address": "http://ae585ec6.ngrok.io/",
			"auth": {
				"accessor": "kMr3iCSlekSN2d1vpPjbjzUk",
				"token": "s.qgVrPa3eKawwDDkeOSXUaWZq"
			},
			"backends": {
				"generic": [
					"cf/7f1a12a9-4a52-4151-bc96-874380d30182/secret",
					"cf/c4073566-baee-48ae-88e9-7c7c7e0118eb/secret"
				],
				"transit": [
					"cf/7f1a12a9-4a52-4151-bc96-874380d30182/transit",
					"cf/c4073566-baee-48ae-88e9-7c7c7e0118eb/transit"
				]
			},
			"backends_shared": {
				"organization": "cf/8d4b992f-cca3-4876-94e0-e49170eafb67/secret",
				"space": "cf/bdace353-e813-4efb-8122-58b9bd98e3ab/secret"
			}
		},
		"label": "hashicorp-vault",
		"name": "my-vault",
		"plan": "shared",
		"provider": null,
		"syslog_drain_url": null,
		"tags": [],
		"volume_mounts": []
	}]
}

The keys of the credentials section are as follows:

  • address - address to the Vault server to make requests against

  • auth.accessor - token accessor which can be used for logging

  • auth.token - token to supply with requests to Vault

  • backends.generic - namespaces in Vault where this token has full CRUD access to the static secret storage ("generic") backend, one at the application level and the other at the service instance level

  • backends.transit - namespaces in Vault where this token has full access to the transit ("encryption as a service") backend, one at the application level and the other at the service instance level

  • backends_shared.organization - namespace in Vault where this token has read-only access to organization-wide data; all instances have read-only access to this path, so it can be used to share information across the organization.

  • backends_shared.space - namespace in Vault where this token has read-write access to space-wide data; all instances have read-write access to this path, so it can be used to share information across the space.

Internals

Architecture and Assumptions

To ease in setup and administration, the HashiCorp Vault Service Broker makes a few assumptions about the Vault setup including:

  • The Vault server is already running and is accessible by the broker.

  • The Vault server may be used by other applications (it is not exclusively tied to Cloud Foundry).

  • All instances of an application will share a token. This goes against the recommended Vault usage, but this is a limitation of the Cloud Foundry service broker model.

  • Any Vault operations performed outside of Cloud Foundry will require users to rebind their instances.

When a new service instance is provisioned using the broker, it will mount the following paths:

  1. Mount the generic backend at /cf/<organization_id>/secret/
  2. Mount the generic backend at /cf/<space_id>/secret/
  3. Mount the generic backend at /cf/<app_id>/secret/
  4. Mount the transit backend at /cf/<app_id>/transit/
  5. Mount the generic backend at /cf/<instance_id>/secret/
  6. Mount the transit backend at /cf/<instance_id>/transit/

The mount operation is idempotent, so service instances in the same organization or space will not re-create the mount. These mount points will be returned to the application in the secret data, so there is no need to "guess" or interpolate these strings.

The read-only organization mount allows for sharing secrets organization wide, and the read-write mount permits sharing secrets between applications in the same Cloud Foundry Space. The transit backend is mounted to provide "encryption-as-a-service" on a per-application level.

After mounting is complete, the broker generates a custom policy specific for this instance which grants the following:

  • Read-only access to "cf/<organization_id>/*"
  • Read-write access to "cf/<space_id>/*"
  • Full access to "cf/<instance_id>/*"

This policy is named "cf-<instance_id>" and can be further customized outside of Cloud Foundry by a Vault administrator.

Next the broker creates a new token role. This role creates a periodic token with the above policy attached. This does not create the token yet, just the role for generating the token.

When a service instance is bound to an application, the broker performs the following operations:

  • Create a new token against the previous "cf-<instance_id>" role.

  • Start a background process to renew this token

  • Generate and returning the binding credentials (see above for the schema)

It is important to note that all instances of a Cloud Foundry application will share the same vault_token. This is not the recommended pattern for using Vault, but it is an existing limitation of the service broker model.

Unbinding and Deleting

When unbinding from a service or deleting the service broker entirely, the broker deletes an instance-specific data. For safety, the broker does not delete an space or organization-specific mounts, even if there are no remaining service brokers using it.

Broker Vault Token Permissions

The Cloud Foundry Vault Broker requires a VAULT_TOKEN to operate. This token should have elevated permissions in Vault, as it will be responsible for generating new mounts and committing data to its internal data structure.

Here is a sample policy to assign to this token:

# Manage internal state under "/broker", but since this token is going to
# generate children, it needs full management of the "/cf/*" space
path "/cf/" {
  capabilities = ["list"]
}

path "/cf/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}

# List all mounts
path "sys/mounts" {
  capabilities = ["read", "list"]
}

# Create mounts under the "/cf/" prefix
path "sys/mounts/cf/*" {
  capabilities = ["create", "update", "delete"]
}

# Create policies with the "cf-*" prefix
path "sys/policies/acl/cf-*" {
  capabilities = ["create", "update", "delete"]
}

# Create token role
path "/auth/token/roles/cf-*" {
  capabilities = ["create", "update", "delete"]
}

# Create tokens from role
path "/auth/token/create/cf-*" {
  capabilities = ["create", "update"]
}

# Revoke tokens by accessor
path "/auth/token/revoke-accessor" {
  capabilities = ["create", "update"]
}

Additionally, this token should be a periodic token. The Cloud Foundry Vault Broker will renew this periodic token automatically.

  1. Authenticate as a root token or user with sudo privilege in Vault (this is required to create a periodic token):
$ vault auth <token>
  1. Create the policy specific for the broker:
$ vault write cf-broker cf-broker.hcl
  1. Create a periodic token
$ vault token-create -period="30m" -orphan -policy=cf-broker

Grab the value for "token" and store it somewhere safe for now - you will need this when configuring the HashiCorp Vault Service Broker.

Service Broker Configuration

The service broker is designed to be configured using environment variables. It currently recognizes the following.

  • SERVICE_DESCRIPTION (default: "HashiCorp Vault Service Broker") - description of the service to show in the marketplace

  • SERVICE_ID (default: "0654695e-0760-a1d4-1cad-5dd87b75ed99") - UUID of the broker

  • SERVICE_NAME (default: "hashicorp-vault") - name of the service to show in the marketplace

  • SERVICE_TAGS (default: none) - comma-separated list of tags for the service

  • PLAN_NAME (default: "shared") - the name of the plan in the marketplace

  • PLAN_DESCRIPTION (default: "Secure access to Vault's storage and transit backends") - description of the plan in the marketplace

  • PORT (default: "8000") - port to bind and listen on as the server (broker)

  • VAULT_ADDR (default: "https://127.0.0.1:8200") - address to the Vault server

  • VAULT_ADVERTISE_ADDR (default: "$VAULT_ADDR") - address to advertise to clients as Vault's address. This defaults to the value supplied for VAULT_ADDR, but can be overridden. This is most useful when the broker communicates to Vault on a local subnet, but clients communicate through a public subnet.

  • VAULT_RENEW (default: true) - enable renewal of the token provided to Vault. The token given to Vault is assumed to be a periodic token, and the broker will automatically renew it to prevent it from expiring. If an out-of-band process is managing the renewal, disable this by setting it to "false".

  • VAULT_TOKEN (default: none) - token to authenticate the broker to Vault. This token should have permission to mount and unmount backends, read, list, and delete paths, and create tokens with role permissions. Please see the Vault Token Permissions section for more information on the requirements for this token.

  • VAULT_NAMESPACE - (default: none) - namespace to use for all calls within Vault

  • SECURITY_USER_NAME - (default: none) - username for basic auth

  • SECURITY_USER_PASSWORD - (default: none) - password for basic auth

Providing Configuration Through CredHub

Any of the Vault Service Broker's environment variables can be set through CredHub. Authenticating to CredHub is typically done by using a UAA server. To configure this, the following environment variables must be set:

  • CREDHUB_URL (default: none) - CredHub's base URL (ex. "https://example.com")
  • UAA_ENDPOINT (default: none) - UAA's base URL (ex. "http://localhost:8080/uaa")
  • UAA_CLIENT_NAME (default: none) - Client name to use when gaining CredHub auth token through UAA
  • UAA_CLIENT_SECRET (default: none) - Client secret to use when gaining CredHub auth token through UAA

The following optional parameters are also available:

  • UAA_CA_CERTS (default: none) - CA certs to use when authenticating to UAA
  • UAA_SKIP_VERIFICATION (default: false) - Skip verifying certificates when calling UAA
  • UAA_INSECURE_ALLOW_ANY_SIGNING_METHOD (default: false) - Allow any signing method when verifying UAA certs

Once this is set, Vault will check CredHub for all environment variables listed above. All variables must be prefixed with "VAULT_SERVICE_BROKER_". For example:

  • VAULT_SERVICE_BROKER_SECURITY_USER_PASSWORD: "$ecure_pa$$w0rd"
  • VAULT_SERVICE_BROKER_VAULT_RENEW: "false"
  • VAULT_SERVICE_BROKER_SERVICE_TAGS: "production,security"

Please keep the following in mind:

  • You may set configuration through both CredHub and environment variables
  • CredHub is preferred, so if a variable exists in both places, the CredHub value will prevail
  • The values for the CredHub variables must be given as strings in the same format as you would an environment variable

Granting Access to Other Paths

The service broker has an opinionated setup of policies and mounts to provide a simplified user experience for getting started which matches the organizational model of Cloud Foundry. However an application may require access to existing data or backends.

Once the broker creates the policy for a service id cf-<instance_id> that policy may be modified by a user with permissions in Vault to add additional capabilities. The default policy can be discovered by reading it:

$ vault policy read cf-<instance_id>
# ...

Append any additional rules to the end.

Global Standard Broker

The default configuration and examples above use a "space scoped" broker. For larger installations, it may be desirable to run a centralized instance of the broker that is accessible to all spaces and applications in the system. This is generally called a "standard broker" in Cloud Foundry terminology. To deploy a global broker, an admin must add, publish, and permit access as follows.

First, create the broker. Note the lack of --space-scoped as compared to the previous commands.

$ cf create-service-broker vault-broker "${AUTH_USERNAME}" "${AUTH_PASSWORD}" "https://${BROKER_URL}"

To verify the broker was created:

$ cf service-access
# ...

broker: vault-broker
   service           plan     access   orgs
   hashicorp-vault   shared   none

Notice the access is listed as "none". This broker will not appear in the marketplace until activated by an admin. To activate, run:

$ cf enable-service-access hashicorp-vault

It is possible to restrict the access to particular organizations or plans.

$ cf enable-service-access hashicorp-vault -o my-org

Verify the plan is enabled:

$ cf service-access
# ...

broker: vault-broker
   service           plan     access   orgs
   hashicorp-vault   shared   all

And check in the marketplace

$ cf marketplace
service           plans             description
hashicorp-vault   shared            HashiCorp Vault Service Broker
# ...

Now all spaces have access to this centralized broker!

Contributing

  1. Clone the repo
  2. Make changes on a branch
  3. Test changes
  4. Submit a Pull Request to GitHub

vault-service-broker's People

Contributors

armon avatar benashz avatar calvn avatar chrishoffman avatar deejross avatar dependabot[bot] avatar hashicorp-copywrite[bot] avatar jasonodonnell avatar jefferai avatar mdeggies avatar schneiderl avatar sethvargo avatar tomhjp avatar tvoran avatar tyrannosaurus-becks avatar zmb3 avatar

Stargazers

 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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-service-broker's Issues

Is there a way to create mounts based on the names instead of GUIDs ?

Hi, Currently the namespaces created dynamically for secret mounts looks very random and tightly coupled to the GUIDs generated on a CF/PCF ecosystem. Can this be made a bit name based instead of GUID for ease of management ?

 "VCAP_SERVICES": {
  "hashicorp-vault": [
   {
    "credentials": {
     "address": "https://blah.amazonaws.com:8200/",
     "auth": {
      "accessor": "25afc1eb-5ef7-1cbf-2aca-62468ac913af",
      "token": "d3a9123e-5c19-7562-432e-ebb763bae079"
     },
     "backends": {
      "generic": "cf/7abe1cfa-4a17-407a-8bf9-09f1544951c7/secret",
      "transit": "cf/7abe1cfa-4a17-407a-8bf9-09f1544951c7/transit"
     },
     "backends_shared": {
      "organization": "cf/9a9fb216-42ae-4bfb-865e-69b44e256a98/secret",
      "space": "cf/d0cae1cd-e4e2-44f4-9718-a1f6d54d605b/secret"
     }
    },
    "label": "hashicorp-vault",
    "name": "aws-vault",
    "plan": "shared",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [
     ""
    ],
    "volume_mounts": []
   }
 cf org my-org --guid
9a9fb216-42ae-4bfb-865e-69b44e256a98
cf space my-space --guid
d0cae1cd-e4e2-44f4-9718-a1f6d54d605b

It looks pretty weird since it is very random

Ideally speaking these would have been better placed if it were mounted based on names.

cf/my-org/secret
cf/my-space/secret
cf/my-app/secret (instead of the instance id)

GitHub Actions - deprecated warnings found - action required!

Workflow Name: test
Branch: main
Run URL: https://github.com/hashicorp/vault-service-broker/actions/runs/4176707836

save-state deprecation warnings: 0
set-output deprecation warnings: 1
node12 deprecation warnings: 2

Please review these deprecation warnings as soon as possible and merge in the necessary updates.

GitHub will be removing support for these commands and plan to fully disable them on 31st May 2023. At this time, any workflow that still utilizes these commands will fail. See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/.

GitHub have not finalized a date for deprecating node12 yet but have indicated that this will be summer 2023. So it is advised to switch to node16 asap. See https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

If you need any help, please reach out to us in #team-rel-eng.

failed to start broker failed to create mounts: x509: certificate signed by unknown authority

Hi Team,

While Deploying cloud-foundry-vault-service-broker as below
https://www.hashicorp.com/blog/cloud-foundry-vault-service-broker

Whenever we do cf start vault-broker

I have tried putting but no use. Please guide

cf set-env vault-broker VAULT_TOKEN "*************"
cf set-env vault-broker SECURITY_USER_NAME "vadmin"
cf set-env vault-broker SECURITY_USER_PASSWORD "*********"
cf set-env vault-broker TRUST_CERTS "10.119.69.204:8200"
cf set-env vault-broker VAULT_SKIP_VERIFY "true"

sys/policies/acl/cf 403 on binding vault to app

Hello I'm getting this 403 error on binding the app to the vault service:

$ cf bind-service my-app sbil-vault
Binding service sbil-vault to app my-app in org SvcsIT-AnEOrg / space devops as Rafael_Prado...
Service broker error: failed to create policy cf-eabb9d6c-2f3c-43ef-a76d-4e0e25eda128: Error making API request.
URL: PUT http://svcsltslab1.com/v1/sys/policies/acl/cf-eabb9d6c-2f3c-43ef-a76d-4e0e25eda128

Code: 403. Errors:
* 1 error occurred:
* permission denied
FAILED

I handled it by adding this to the cf-broker.hcl:

path "sys/policies/acl/cf-*" {
  capabilities = ["create", "update", "delete"]
}

This is not on the README.md doc, I was going to generate a PR for it but as I'm very new to vault and I don't know if it's correct to add this policy I believe that I should first ask about it here :)

Database error when deleting app using vault broker

Application was not working due to a permission issue with the token (Renewable:false) so we wanted to stop the app and delete it and create it again.
Only way out is purge-service-instance

C:\Projects\HashicorpVaultImpl>cf delete HashicorpVaultImpl -r

Really delete the app HashicorpVaultImpl?> y
Deleting app HashicorpVaultImpl in org Test / space testspace as gundave...
FAILED
Server error, status code: 500, error code: 10011, message: Database error

C:\Projects\HashicorpVaultImpl>cf us HashicorpVaultImpl vault
Unbinding app HashicorpVaultImpl from service vault in org Test / space testspac
e as gundave...
FAILED
Service instance vault: Service broker error: failed to revoke accessor 156bf284
-0c21-7a51-424f-0aeff8a9110a: Error making API request.

URL: POST https://vault.manulife.com:8200/v1/auth/token/revoke-accessor
Code: 400. Errors:

  • 1 error(s) occurred:

  • invalid accessor

C:\Projects\HashicorpVaultImpl>cf unbind-service HashicorpVaultImpl vault
Unbinding app HashicorpVaultImpl from service vault in org Test / space testspac
e as gundave...
FAILED
Service instance vault: Service broker error: failed to revoke accessor 156bf284
-0c21-7a51-424f-0aeff8a9110a: Error making API request.

URL: POST https://vault.manulife.com:8200/v1/auth/token/revoke-accessor
Code: 400. Errors:

  • 1 error(s) occurred:

  • invalid accessor

The service broker failed to connect to a Vault server configured with a self-signed certificate

I just deployed the vault service broker v0.5.3 with VAULT_SKIP_VERIFY: true for the environment variable and got this error when connecting to a test Vault cluster configured with a self-signed certificate.

[ERR] failed to start broker: failed to create mounts: Get https://10.9.202.7/v1/sys/mounts: x509: certificate signed by unknown authority

Another user ran into the same problem as logged in this issue ( #45). Based on the comments, it looked like the VAULT_SKIP_VERIFY env variable is not currently supported in the Vault service broker. When looking the source code (https://github.com/hashicorp/vault-service-broker/blob/master/main.go#L40), the service broker first calls this function from Hashicorp vault API ("github.com/hashicorp/vault/api"):

vaultClientConfig := api.DefaultConfig()

This function returns a vault config containing an HTTP client with the needed transport TLS configurations properly picked up from the environment variables (VAULT_SKIP_VERIFY) and should be able to connect to a Vault cluster with a self-signed certificate. However when the next statement (https://github.com/hashicorp/vault-service-broker/blob/master/main.go#L41) is executed, a new HTTP client is created for Vault client config,

vaultClientConfig.HttpClient = cleanhttp.DefaultClient()

As this new HTTP client does not perform any further transport TLS configurations from the environment variables such as VAULT_SKIP_VERIFY, it would fail to make an SSL connection to Vault cluster with a self-signed certificate.

Possible resolutions for supporting the Vault cluster with self-signed certificate:

Option 1. If we can remove the following statement,
vaultClientConfig.HttpClient = cleanhttp.DefaultClient()

and just use the HTTP client (cleanhttp.DefaultPooledClient) created as part of api.DefaultConfig(), but there is a warning message on using the DefaultPooledClient:

Do not use this function for transient clients as it can leak file descriptors over time. Only use this for clients that will be re-used for the same host(s).

therefore cleanhttp.DefaultPooledClient might not be suitable for the service broker.

Option 2: If we want to continue to use the cleanhttp.DefaultClient, we would need to add the following code to configure TLS configurations for the service broker (https://github.com/hashicorp/vault-service-broker/blob/master/main.go).

func main() {
...
// Setup the vault client
vaultClientConfig := api.DefaultConfig()
vaultClientConfig.HttpClient = cleanhttp.DefaultClient()
if err := configureHttpClient(vaultClientConfig); err != nil {
logger.Fatal("[ERR] failed to configure the HTTP client", err)
}
...
}

func configureHttpClient(config *api.Config) error {
transport := config.HttpClient.Transport.(*http.Transport)
transport.TLSHandshakeTimeout = 10 * time.Second
transport.TLSClientConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}
if err := http2.ConfigureTransport(transport); err != nil {
return err
}
if err := config.ReadEnvironment(); err != nil {
return err
}
config.HttpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
config.Backoff = retryablehttp.LinearJitterBackoff
config.MaxRetries = 2
return nil
}

could you please take a look to see if the service broker code can be changed to support the Vault cluster with self-signed certificates?

Expired token prevents service unbind

I'm not terribly familiar with Vault yet so please forgive if I'm missing something

I created vault service broker and it is working correctly. I'm using the sample policy in the readme doc for the broker token.

I created a service successfully and bound it to my app, and was able to write secrets to the generic space backend and read them from my app (python app using hvac).

It appears my token has expired and I can no longer auth with it.

When I attempt to unbind my service, I get the following

cf unbind-service appname vaultservice
Unbinding app appname from service vaultservice in org org / space space as [email protected]...
Unexpected Response
Response code: 502
CC code:       10001
CC error code: CF-ServiceBrokerBadResponse
Request ID:    63df3eda-87f3-4e17-7369-ddf1e030d506
Request ID:    0c1b0c37-6b67-4c66-6df2-f44ded7d4eaf::f55eefdf-895c-4e3e-8e15-f84f3ab88eee
Description:   Service instance vault: Service broker error: failed to revoke accessor 12312b67-3693-ac35-eb52-1c515cac547b: Error making API request.

URL: POST https://vault.domain.com:8200/v1/auth/token/revoke-accessor
Code: 400. Errors:

* 1 error(s) occurred:

* invalid accessor
FAILED

Here are logs from vault broker

2017-05-17T12:57:42.97-0700 [APP/0] OUT [INFO] unbinding service df0fe535-1143-4d24-9194-655bd2eee8ea for instance b8759394-5382-4c6c-8a00-4736d75cff18
2017-05-17T12:57:42.97-0700 [APP/0] OUT [DEBUG] reading cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.00-0700 [APP/0] OUT [DEBUG] decoding binding info for cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.00-0700 [APP/0] OUT [DEBUG] revoking accessor 29912b67-3693-ac35-eb52-1c515cac547b for path cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.01-0700 [RTR/4] OUT vault-broker.apps.domain.com - [17/05/2017:19:57:42.973 +0000] "DELETE /v2/service_instances/b8759394-5382-4c6c-8a00-4736d75cff18/service_bindings/df0fe535-1143-4d24-9194-655bd2eee8ea?plan_id=0654695e-0760-a1d4-1cad-5dd87b75ed99.shared&service_id=0654695e-0760-a1d4-1cad-5dd87b75ed99 HTTP/1.1" 500 0 260 "-" "HTTPClient/1.0 (2.7.1, ruby 2.2.4 (2015-12-16))" [REDACTED]:55945 x_forwarded_for:"[REDACTED], [REDACTED]" x_forwarded_proto:"https" vcap_request_id:fffdb4f3-8487-4ec3-7413-334e9b87a726 response_time:0.041498743 app_id:564d39aa-a080-4b28-a5f3-f862109ab73e
2017-05-17T12:57:43.01-0700 [RTR/4] OUT
2017-05-17T12:57:43.16-0700 [APP/0] OUT [INFO] unbinding service df0fe535-1143-4d24-9194-655bd2eee8ea for instance b8759394-5382-4c6c-8a00-4736d75cff18
2017-05-17T12:57:43.16-0700 [APP/0] OUT [DEBUG] reading cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.17-0700 [APP/0] OUT [DEBUG] decoding binding info for cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.18-0700 [APP/0] OUT [DEBUG] revoking accessor 29912b67-3693-ac35-eb52-1c515cac547b for path cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.18-0700 [RTR/3] OUT vault-broker.apps.domain.com - [17/05/2017:19:57:43.160 +0000] "DELETE /v2/service_instances/b8759394-5382-4c6c-8a00-4736d75cff18/service_bindings/df0fe535-1143-4d24-9194-655bd2eee8ea?plan_id=0654695e-0760-a1d4-1cad-5dd87b75ed99.shared&service_id=0654695e-0760-a1d4-1cad-5dd87b75ed99 HTTP/1.1" 500 0 260 "-" "HTTPClient/1.0 (2.7.1, ruby 2.2.4 (2015-12-16))" [REDACTED]:53419 x_forwarded_for:"[REDACTED], [REDACTED]" x_forwarded_proto:"https" vcap_request_id:3486f6f0-eadd-4fe9-533a-f3614ae0dcd8 response_time:0.026972471 app_id:564d39aa-a080-4b28-a5f3-f862109ab73e
2017-05-17T12:57:43.18-0700 [RTR/3] OUT
2017-05-17T12:57:43.34-0700 [APP/0] OUT [INFO] unbinding service df0fe535-1143-4d24-9194-655bd2eee8ea for instance b8759394-5382-4c6c-8a00-4736d75cff18
2017-05-17T12:57:43.34-0700 [APP/0] OUT [DEBUG] reading cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.36-0700 [APP/0] OUT [DEBUG] decoding binding info for cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.36-0700 [APP/0] OUT [DEBUG] revoking accessor 29912b67-3693-ac35-eb52-1c515cac547b for path cf/broker/b8759394-5382-4c6c-8a00-4736d75cff18/df0fe535-1143-4d24-9194-655bd2eee8ea
2017-05-17T12:57:43.37-0700 [RTR/1] OUT vault-broker.domain.com - [17/05/2017:19:57:43.336 +0000] "DELETE /v2/service_instances/b8759394-5382-4c6c-8a00-4736d75cff18/service_bindings/df0fe535-1143-4d24-9194-655bd2eee8ea?plan_id=0654695e-0760-a1d4-1cad-5dd87b75ed99.shared&service_id=0654695e-0760-a1d4-1cad-5dd87b75ed99 HTTP/1.1" 500 0 260 "-" "HTTPClient/1.0 (2.7.1, ruby 2.2.4 (2015-12-16))" [REDACTED]:59200 x_forwarded_for:"[REDACTED], [REDACTED]" x_forwarded_proto:"https" vcap_request_id:75a78298-5d81-4215-6e93-f22298f9d440 response_time:0.03506014 app_id:564d39aa-a080-4b28-a5f3-f862109ab73e

How an bound app can connect to a Vault cluster in High Availability (HA) mode?

We're setting up a Vault cluster with 3 nodes using Consul for the backend storage in HA mode. VAULT_ADVERTISE_ADDR environment variable is the address to advertise to bound applications as the Vault's address. If this is the single IP address of one of Vault nodes and when this node is unavailable, how can the app know what are the IP addresses of the other Vault nodes for connect to in the failover?

Do we need to add a load balancer in front of the Vault nodes and use the IP/DNS of the load balancer in VAULT_ADVERTISE_ADDR environment variable? It looked like the Vault service broker assumes that bound applications should access the Vault HA cluster via a load balancer, but could you please confirm.

If we need to provide a list of IP addresses of all Vault nodes in HA cluster to a bound app, so the app can directly connect to first Vault node and fail over to the other node addresses in the list if first node is unavailable. Does Vault service broker support the direct node connection with Vault HA cluster? We can put multiple IP addresses in VAULT_ADVERTISE_ADDR, but I'm not sure if it's recommended. Should the Vault service broker introduce another environment variable (VAULT_ADVERTISE_ADDRS) to hold multiple IP addresses for HA cluster use case?

Support for PKI Backend ?

Like generic or transit backends , do you think the PKI backend should also be established with mounts and policies on the servers and the same be populated on the VCAP_SERVICES ?

Support for Namespaces

The enterprise edition of Vault supports namespaces and the service broker should too. The destination namespace is added to the HTTP request in the form of the X-Vault-Namespace header, or by calling SetNamespace(namespace string) using github.com/hashicorp/vault/api.Client.

Add Dockerfile

I'd like to run this broker inside of a docker environment.
Can you add this to your dockerhub?
Is the correct approach to it to hashicorp/docker-hub-images?

Thank you!

Error renewing Vault token while starting broker

   2018-12-05T22:44:52.23-0800 [APP/PROC/WEB/0] OUT [INFO] starting broker
   2018-12-05T22:44:52.23-0800 [APP/PROC/WEB/0] OUT [DEBUG] creating mounts cf/broker=generic
   2018-12-05T22:44:52.58-0800 [APP/PROC/WEB/0] OUT [ERR] renew-token: failed to lookup client vault token: Error making API request.
   2018-12-05T22:44:52.58-0800 [APP/PROC/WEB/0] OUT URL: PUT http://a6a3bbbc.ngrok.io/v1/auth/token/renew-self
   2018-12-05T22:44:52.58-0800 [APP/PROC/WEB/0] OUT Code: 400. Errors:
   2018-12-05T22:44:52.58-0800 [APP/PROC/WEB/0] OUT * invalid lease ID
   2018-12-05T22:44:52.97-0800 [APP/PROC/WEB/0] OUT [DEBUG] restoring bindings

GO Buildpack Issue - Staging failed Bluemix CF

Hi there! Im trying to deploy your vault service broker on Bluemix cloud foundry. I followed the steps shown on your github readme but, but could not get the vault-broker to start after pushing to cf.

after running cf start for the first time, I received the following error during the staging process:

Staging...
-------> Buildpack version 1.7.5
file:///tmp/buildpacks/6ac565cf5df70e40a10479c1f20d4b09/dependencies/https___pivotal-buildpacks.s3.amazonaws.com_concourse-binaries_godep_godep-v62-linux-x64.tgz
DEPENDENCY MISSING IN MANIFEST: go 1.7
It looks like you're trying to use go 1.7.
Unfortunately, that version of go is not supported by this build pack.
The versions of go supported in this buildpack are:
- 1.6.1
- 1.6
- 1.5.3
- 1.4.3
If you need further help, start by reading: http://github.com/cloudfoundry/go-buildpack/releases.
Failed to compile droplet
Exit status 223
Destroying container
Successfully destroyed container

FAILED
BuildpackCompileFailed

I then changed the manifest.yml so that the GOVERSION env variable was go1.6.1 instead of go1.7. I also changed the GOVERSION variable in the Makefile to go1.6.1.

However, running the broker like this resulted in another error:

Staging...
-------> Buildpack version 1.7.5
file:///tmp/buildpacks/6ac565cf5df70e40a10479c1f20d4b09/dependencies/https___pivotal-buildpacks.s3.amazonaws.com_concourse-binaries_godep_godep-v62-linux-x64.tgz
-----> Installing go1.6.1... done
 !     Error: Cloud Foundry does not support the govendor package manager
 !     We currently only support the 'Godep' package manager for go apps
 !     For support please file an issue: https://github.com/cloudfoundry/go-buildpack/issues
 !     
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223
Destroying container
Successfully destroyed container

FAILED
BuildpackCompileFailed

I found someone post a similar error here: cloudfoundry/go-buildpack#40. I followed a suggestion to push the app with an updated go build pack like so:

cf push my_app -b https://github.com/cloudfoundry/go-buildpack

This led to the following error here:

2017-02-28T14:39:16.14-0500 [API/4]      OUT Created app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d
2017-02-28T14:39:18.52-0500 [API/8]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"route"=>"f7ca19bf-1564-403f-98a3-33fbfaf87393"})
2017-02-28T14:39:49.23-0500 [API/9]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"environment_json"=>"PRIVATE DATA HIDDEN"})
2017-02-28T14:39:57.92-0500 [API/2]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"environment_json"=>"PRIVATE DATA HIDDEN"})
2017-02-28T14:40:56.72-0500 [API/1]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"environment_json"=>"PRIVATE DATA HIDDEN"})
2017-02-28T14:41:18.43-0500 [API/0]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"environment_json"=>"PRIVATE DATA HIDDEN"})
2017-02-28T14:41:26.52-0500 [API/5]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"environment_json"=>"PRIVATE DATA HIDDEN"})
2017-02-28T14:41:45.88-0500 [API/5]      OUT Updated app with guid 68055fce-cc25-47a7-a8fe-20430fdf723d ({"state"=>"STARTED"})
2017-02-28T14:41:46.46-0500 [STG/0]      OUT Creating container
2017-02-28T14:41:54.51-0500 [STG/0]      OUT Successfully created container
2017-02-28T14:41:54.51-0500 [STG/0]      OUT Downloading app package...
2017-02-28T14:41:54.73-0500 [STG/0]      OUT Downloaded app package (212.1K)
2017-02-28T14:41:54.73-0500 [STG/0]      OUT Staging...
2017-02-28T14:41:57.43-0500 [STG/0]      OUT -------> Buildpack version 1.7.19
2017-02-28T14:41:57.84-0500 [STG/0]      OUT https://buildpacks.cloudfoundry.org/dependencies/godep/godep-v79-linux-x64-9e37ce0f.tgz`
2017-02-28T14:41:58.49-0500 [STG/0]      OUT https://buildpacks.cloudfoundry.org/dependencies/glide/glide-v0.12.3-linux-x64-5b2e71ff.tgz
2017-02-28T14:42:29.31-0500 [STG/0]      ERR Failed to compile droplet
2017-02-28T14:42:29.32-0500 [STG/0]      OUT Exit status 223
2017-02-28T14:42:29.37-0500 [STG/0]      ERR Staging failed: Exited with status 223
2017-02-28T14:42:29.55-0500 [API/6]      ERR Failed to stage application: staging failed

Not sure where to go from here. Any help would be appreciated!

Should different CF apps get different policies?

I've been having a play with the Vault Service Broker and I've successfully deployed it and bound 2 apps deployed on my CF to a Vault service (dev mode, also running on CF).

I was expecting that the apps I bound would each have a token that would be assigned its own policy (albeit with the same contents) , but instead the tokens were both assigned the same policy i.e. there is only 1 broker policy listed in Vault policies.

My question is, is this expected behaviour?

The reason I was hoping the apps would get unique policies would be so that I could assign specific capabilities to different apps e.g. any app can encrypt, only appB can decrypt, or only appA can sign but any app can verify etc. That doesn't seem possible (at least via the broker) with what I am seeing as I can't assign a new policy to an existing token, only change a policy already associated with a token (as you know this is a feature of Vault), which doesn't allow me to give different apps different capabilities as they all use the same policy.

Hopefully I am missing something?

ERR failed to start broker: failed to create mounts

Hi there! I'm following the instructions for starting up the service broker, and I set up a local vault server running at http://127.0.0.1:8200 with a consul backend. I unsealed it and created an periodic orphan token with its lease set to 30 minutes. I set its policy to the .hcl file with the following policies:

# Manage internal state under "/broker", but since this token is going to 
# generate children, it needs full management of the "/cf/*" space 
path "/cf/" {
 capabilities = ["list"]
}

path "/cf/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}

# List all mounts
path "sys/mounts" {
  capabilities = ["read", "list"]
}

# Create mounts under the "/cf/" prefix
path "sys/mounts/cf/*" {
  capabilities = ["create", "update", "delete"]
}

# Create policies with the "cf-*" prefix
path "sys/policy/cf-*" {
  capabilities = ["create", "update", "delete"]
}

# Create token role
path "/auth/token/roles/cf-*" {
  capabilities = ["create", "update", "delete"]
}

# Create tokens from role
path "/auth/token/create/cf-*" {
  capabilities = ["create", "update"]
}

# Revoke tokens by accessor
path "/auth/token/revoke-accessor" {
  capabilities = ["create", "update"]
}

I then set the set the Bluemix apps VAULT_ADDR to http://127.0.0.1:8200 and VAULT_TOKEN to the orphan token with the above policy. However, when running the app, im getting this error during staging:

2017-03-02T14:37:42.37-0500 [STG/0]      OUT github.com/hashicorp/cf-vault-service-broker
2017-03-02T14:38:00.03-0500 [STG/0]      OUT Uploading droplet, build artifacts cache...
2017-03-02T14:38:00.03-0500 [STG/0]      OUT Uploading build artifacts cache...
2017-03-02T14:38:18.34-0500 [STG/0]      OUT Uploading complete
2017-03-02T14:38:19.63-0500 [CELL/0]     OUT Creating container
2017-03-02T14:38:21.08-0500 [CELL/0]     OUT Successfully created container
2017-03-02T14:38:21.49-0500 [CELL/0]     OUT Starting health monitoring of container
2017-03-02T14:38:21.62-0500 [APP/0]      OUT [INFO] starting broker
2017-03-02T14:38:21.62-0500 [APP/0]      OUT [ERR] failed to start broker: failed to create mounts: Get http://127.0.0.1:8200/v1/sys/mounts: dial tcp 127.0.0.1:8200: getsockopt: connection refused
2017-03-02T14:38:21.63-0500 [APP/0]      OUT Exit status 1
2017-03-02T14:38:21.68-0500 [CELL/0]     OUT Destroying container
2017-03-02T14:38:21.70-0500 [API/0]      OUT App instance exited with guid 9679cce7-8682-453a-96ff-fda303724259 payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Exited with status 1\n* cancelled\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1488483501667341551, "version"=>"06447cdf-0339-4f38-a587-8b6aae960da0"}
2017-03-02T14:38:22.65-0500 [CELL/0]     OUT Successfully destroyed container
2017-03-02T14:38:23.30-0500 [STG/0]      OUT Successfully destroyed container
2017-03-02T14:38:24.30-0500 [APP/0]      OUT [INFO] starting broker
2017-03-02T14:38:24.30-0500 [APP/0]      OUT [DEBUG] creating mounts map[string]string{"cf/broker":"generic"}
2017-03-02T14:38:24.30-0500 [APP/0]      OUT [ERR] renew-token: error renewing vault token: Get http://127.0.0.1:8200/v1/auth/token/lookup-self: dial tcp 127.0.0.1:8200: getsockopt: connection refused
2017-03-02T14:38:24.30-0500 [APP/0]      OUT [ERR] failed to start broker: failed to create mounts: Get http://127.0.0.1:8200/v1/sys/mounts: dial tcp 127.0.0.1:8200: getsockopt: connection refused
2017-03-02T14:38:24.32-0500 [CELL/0]     OUT Exit status 0
2017-03-02T14:38:24.35-0500 [CELL/0]     OUT Destroying container
2017-03-02T14:38:24.38-0500 [API/10]     OUT App instance exited with guid 9679cce7-8682-453a-96ff-fda303724259 payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Exited with status 1\n* cancelled\n* cancelled", "crash_count"=>2, "crash_timestamp"=>1488483504344390695, "version"=>"06447cdf-0339-4f38-a587-8b6aae960da0"}
2017-03-02T14:38:24.92-0500 [CELL/0]     OUT Creating container
2017-03-02T14:38:26.15-0500 [CELL/0]     OUT Successfully destroyed container
2017-03-02T14:38:30.29-0500 [CELL/0]     OUT Successfully created container
2017-03-02T14:38:30.80-0500 [CELL/0]     OUT Starting health monitoring of container
2017-03-02T14:38:31.04-0500 [APP/0]      OUT [INFO] starting broker
2017-03-02T14:38:31.06-0500 [APP/0]      OUT [ERR] renew-token: error renewing vault token: Get http://127.0.0.1:8200/v1/auth/token/lookup-self: dial tcp 127.0.0.1:8200: getsockopt: connection refused
2017-03-02T14:38:31.07-0500 [APP/0]      ERR panic: runtime error: invalid memory address or nil pointer dereference
2017-03-02T14:38:31.07-0500 [APP/0]      ERR [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x409d4b]
2017-03-02T14:38:31.07-0500 [APP/0]      ERR panic(0x7a2640, 0xc42000c0a0)
2017-03-02T14:38:31.07-0500 [APP/0]      ERR 	/tmp/cache/go1.7.5/go/src/runtime/panic.go:500 +0x1a1
2017-03-02T14:38:31.07-0500 [APP/0]      ERR 	/tmp/tmp.RJYH8vxKkf/.go/src/github.com/hashicorp/cf-vault-service-broker/broker.go:711 +0x17b
2017-03-02T14:38:31.07-0500 [APP/0]      ERR created by main.(*Broker).Start
2017-03-02T14:38:31.07-0500 [APP/0]      ERR 	/tmp/tmp.RJYH8vxKkf/.go/src/github.com/hashicorp/cf-vault-service-broker/broker.go:102 +0xb88
2017-03-02T14:38:31.08-0500 [APP/0]      OUT Exit status 2
2017-03-02T14:38:31.14-0500 [CELL/0]     OUT Exit status 143
2017-03-02T14:38:31.15-0500 [CELL/0]     OUT Destroying container
2017-03-02T14:38:31.20-0500 [API/6]      OUT App instance exited with guid 9679cce7-8682-453a-96ff-fda303724259 payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Exited with status 2\n* cancelled\n* cancelled", "crash_count"=>3, "crash_timestamp"=>1488483511158440984, "version"=>"06447cdf-0339-4f38-a587-8b6aae960da0"}
2017-03-02T14:38:36.67-0500 [CELL/0]     OUT Successfully destroyed container

Not sure if its having an issue connecting to the local vault server. All the vault commands im running locally like initialization, seal/unseal, and mounting backends all work fine. Any advice would be appreciated!

Is there any plans create a PCF Tile Deployment?

Is there any plans to work with Pivotal to wrap this service broker into a PCF TILE through Partner Tile Deployment? As my company has paid for Enterprise Vault and also has Pivotal Cloud Foundry. It would be nice this wrapped as a PCF Tile, so it eases my time as a platform operator manual go through the steps that Tile Deployment would do in automated fashion. And it makes it easier for my developers to use Vault Credentials.

Support using resolved org and space names instead of GUID

As a vault service broker user, I'd like to define policies in a flexible manner using human readable names. It would be very useful if the broker could use the org and space names instead of GUIDs for the paths.

Org path: /cf/foundation-1/organization-2
Space path: /cf/foundation-1/organization-2/space-1
Service ID: /cf/foundation-1/organization-2/space-1/service-name

This way I could define a policy like

path "/cf/foundation-1/organization-2/*" {
  capabilities = ["create", "read", "update", "delete", "list"]
}

then assign that policy to the user group managing those secrets

vault write auth/ldap/groups/ORG-2-OPS policies=ORG-2-OPS

Bug while renewing the client tokens for the Binds

The handleRenew function does not update the metadata stored in the generic secret backend for the renewed token.

After the first renewal the meta data residing on the broker mount cf/broker/instanceID/bindingID will go stale and there after the renewals won't happen and the logs will complain

2017-06-12T12:07:35.76-0700 [APP/PROC/WEB/0] OUT [DEBUG] renewing token with accessor dda8587a-9983-09ae-cd19-a45f5bd7bd16
2017-06-12T12:07:35.76-0700 [APP/PROC/WEB/0] OUT [WARN] aborting renewing expired token with accessor dda8587a-9983-09ae-cd19-a45f5bd7bd16

The above token under the accessor dda8587a-9983-09ae-cd19-a45f5bd7bd16 is still valid, and renew worthy, but the meta-data stored in the vault has gone stale prompting the above warning.

#vault read cf/broker/53d02677-5b17-4044-ad2d-00de655ceba5/cce5cf96-a531-4efe-8ecb-5f403504ba3f


Key             	Value
---             	-----
refresh_interval	768h0m0s
json            	{"Organization":"9a9fb216-42ae-4bfb-865e-69b44e256a98","Space":"d0cae1cd-e4e2-44f4-9718-a1f6d54d605b","Binding":"cce5cf96-a531-4efe-8ecb-5f403504ba3f","ClientToken":"bd444b78-10da-92ad-5f75-ddfb107d5fdb","Accessor":"dda8587a-9983-09ae-cd19-a45f5bd7bd16","LeaseDuration":432000,"Renew":"2017-06-05T04:59:55.382848343Z","Expires":"2017-06-10T04:59:55.382848343Z"}

#vault auth
Token (will be hidden):
Successfully authenticated! You are now logged in.
token: bd444b78-10da-92ad-5f75-ddfb107d5fdb
token_duration: 15488
token_policies: [cf-53d02677-5b17-4044-ad2d-00de655ceba5 default]

Project still maintained & Unbind + Service deletion not working for mounts

Hey everyone

First of i was wondering if this Broker is still maintained, for example #51 mentioned, that the policy path is not correct anymore and needs to be changed, which is true and would have helped the project or new users to successfully deploy the broker.

I've deployed the broker which works to the point of creating a service and deploying an app with a service-binding, but when i either unbind an app from the service or delete the service instance the mounts in Vault still persist and do not get deleted. The only mounts in Vault that get deleted are the once from the Service itself when deleted, but a Service Unbind or deletion of an App which was bound to vault does not delete the mounts in vault.

I could only see the log's on the brokers deprovision function in broker.go for the GUID of the Service in CF, the all the Apps GUID's still stay in vault. This behaviour would end up in a situation where Vault would persist lots of Secret Path's from App's that Customers deleted or unbound from the service which i think shouldn't be.

The readme states that those mounts should get deleted.

Any info about the maintenance state of this project and maybe the problem mentioned above would be greatly appreciated.

Thanks in advance

Error binding to Vault

   2018-12-05T22:47:17.81-0800 [APP/PROC/WEB/0] OUT [INFO] binding service f84d97f8-7cf6-4a6a-899c-2e4771bbba69 to instance bd1b775a-c86d-4e41-bea0-c9d827f957b6
   2018-12-05T22:47:17.81-0800 [APP/PROC/WEB/0] OUT [DEBUG] creating token with role cf-bd1b775a-c86d-4e41-bea0-c9d827f957b6
   2018-12-05T22:47:18.10-0800 [APP/PROC/WEB/0] OUT [ERR] failed to create token with role cf-bd1b775a-c86d-4e41-bea0-c9d827f957b6: Error making API request.  URL: POST http://a6a3bbbc.ngrok.io/v1/auth/token/create/cf-bd1b775a-c86d-4e41-bea0-c9d827f957b6 Code: 400. Errors:  * unknown role cf-bd1b775a-c86d-4e41-bea0-c9d827f957b6

using name-space in vault

when using a vault namespace the service broker puts its information correctly in to the vault. When I try to bind to a service the policy fails to create. It looks like the policy write is not appending the namespace to the policy write. I was set up with a vault token created based on the service-broker sample policy. I added all of the namespace entry points to the policy to cover coming in through nested namespace. /devops/cicd as namespace
NOTE: the token and policy I created where in the namespace.

2019-02-25T10:48:58.05-0600 [APP/PROC/WEB/0] OUT [DEBUG] creating new policy cf-8cdb5f48-0315-44da-b912-00ab1677ffb9 2019-02-25T10:48:58.16-0600 [APP/PROC/WEB/0] OUT [ERR] failed to create policy cf-8cdb5f48-0315-44da-b912-00ab1677ffb9: Error making API req uest. URL: PUT https://hcvault-nonprod.dell.com/v1/sys/policies/acl/cf-8cdb5f48-0315-44da-b912-00ab1677ffb9 Code: 403. Errors: * 1 error occu rred: * permission denied 2019-02-25T10:48:58.16-0600 [RTR/1] OUT vault-broker-hilarious-swan.ausvdc02.pcf.dell.com - [2019-02-25T16:48:57.745+0000] "PUT /v2/service_ instances/8cdb5f48-0315-44da-b912-00ab1677ffb9/service_bindings/f505dfa2-b30f-41aa-be38-f3d0b2da55ce HTTP/1.1" 500 428 284 "-" "HTTPClient/1.0 (2.8.3, ruby 2.4.2 (2017-09-14))" "10.32.27.76:58798" "172.16.1.8:61030" x_forwarded_for:"10.175.172.11, 10.32.27.76" x_forwarded_proto:"https" vcap_request_id:"d61ddf9e-989e-4f4f-465f-1f6ac642b9e1" response_time:0.416970695 app_id:"24180243-0a86-4e82-a3ab-8626ed5800fc" app_index:"0" x _b3_traceid:"f9e7bfaa05814ef6" x_b3_spanid:"f9e7bfaa05814ef6" x_b3_parentspanid:"-"

Broker crashes after starting

Successfully installed and configured vault-service-broker. I was able to create a service and bind it to an application. The application was able to successfully authenticate and retrieve secrets from its space. At some point the service broker went down. When I tried to restart the broker, the broker's token had expired. Created a new token and restaged. The broker now crashes shortly startup after it fails to renew a token. I haven't been able to locate the token via the token's accessor. How do I remove the bad token or correct the permission?

The broker's log:

2017-03-22T11:35:41.54-0400 [CELL/0]     OUT Creating container
2017-03-22T11:35:41.90-0400 [CELL/0]     OUT Successfully created container
2017-03-22T11:35:42.61-0400 [CELL/0]     OUT Starting health monitoring of container
2017-03-22T11:35:42.67-0400 [APP/0]      OUT [INFO] starting broker
2017-03-22T11:35:42.67-0400 [APP/0]      OUT [DEBUG] creating mounts map[string]string{"cf/broker":"generic"}
2017-03-22T11:35:42.79-0400 [APP/0]      OUT [DEBUG] restoring bindings
2017-03-22T11:35:42.79-0400 [APP/0]      OUT [DEBUG] listing directory "cf/broker/"
2017-03-22T11:35:42.79-0400 [APP/0]      OUT [INFO] sleeping for 9m31s
2017-03-22T11:35:42.81-0400 [APP/0]      OUT [INFO] restoring info for instance 06431075-2718-449b-9186-3cf06e3d5c12
2017-03-22T11:35:42.83-0400 [APP/0]      OUT [DEBUG] decoding bind data from cf/broker/06431075-2718-449b-9186-3cf06e3d5c12
2017-03-22T11:35:42.83-0400 [APP/0]      OUT [DEBUG] listing directory "cf/broker/06431075-2718-449b-9186-3cf06e3d5c12/"
2017-03-22T11:35:42.84-0400 [APP/0]      OUT [INFO] restoring bind for instance 06431075-2718-449b-9186-3cf06e3d5c12 for binding dc9cd23b-0b83-4ad4-960f-3f3bf2d0d573
2017-03-22T11:35:42.84-0400 [APP/0]      OUT [DEBUG] reading bind from cf/broker/06431075-2718-449b-9186-3cf06e3d5c12/dc9cd23b-0b83-4ad4-960f-3f3bf2d0d573
2017-03-22T11:35:42.86-0400 [APP/0]      OUT [DEBUG] decoding bind data from cf/broker/06431075-2718-449b-9186-3cf06e3d5c12/dc9cd23b-0b83-4ad4-960f-3f3bf2d0d573
.
.
.
2017-03-22T11:35:43.27-0400 [APP/0]      OUT [INFO] restored 6 binds and 8 instances
2017-03-22T11:35:43.28-0400 [APP/0]      OUT [INFO] starting server on :8080
2017-03-22T11:35:44.66-0400 [CELL/0]     OUT Container became healthy
2017-03-22T11:35:47.86-0400 [APP/0]      OUT [DEBUG] renewing token with accessor 81199bc3-22b6-0337-3c56-b66fd8c3a03b
2017-03-22T11:35:47.90-0400 [APP/0]      OUT [ERR] token renewal failed: Error making API request.
2017-03-22T11:35:47.90-0400 [APP/0]      OUT URL: PUT https://vault.dev:443/v1/auth/token/renew
2017-03-22T11:35:47.90-0400 [APP/0]      OUT Code: 403. Errors:
2017-03-22T11:35:47.90-0400 [APP/0]      OUT * permission denied
2017-03-22T11:35:47.90-0400 [APP/0]      OUT Exit status 1
2017-03-22T11:35:47.91-0400 [CELL/0]     OUT Exit status 0
2017-03-22T11:35:47.94-0400 [CELL/0]     OUT Destroying container
2017-03-22T11:35:47.95-0400 [API/1]      OUT App instance exited with guid f1e936a3-194e-4002-95d0-796045e4f101 payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Exited with status 1\n* cancelled\n* cancelled", "crash_count"=>7, "crash_timestamp"=>1490196947934464113, "version"=>"9ef948c3-b7b6-4d46-b273-ff95054d64ba"}
2017-03-22T11:35:48.37-0400 [CELL/0]     OUT Successfully destroyed container

Vault cli add and update secret

Goal

Add and update (without overwriting) secret into Vault

Vault server

Issue

I read that it is possible Vault CLI KV patch. Also, by default the secret engine KV with the path secret/. https://www.vaultproject.io/intro/getting-started/secrets-engines.html

The service broker create path under cf/ and it's not using the KV by default. I try to modify enable the secret engine with cf/ path. When I try to create a new Vault service, I have this error

error alert message,Service broker error: failed to create mounts 

### Questions
* How can I fix it?
* How do you add and update token? Do you use the Vault cli KV?



Examples of how to use the service broker

Hi there - I was just checking this out and it seems like an important part is missing. Is there a simple example of how to use the service broker in a application? Spring maybe?

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.