Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CredHub's CF Instance Identity roles #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Support CredHub's CF Instance Identity roles #2

wants to merge 1 commit into from

Conversation

46bit
Copy link

@46bit 46bit commented Aug 13, 2020

Hi Andy 👋 This is to address #1.

What

Cloud Foundry provides all apps with certificates containing their identity, a system called Instance Identity [1]. You can use these certificates to connect to CredHub using Mutual TLS, and when you do you get the role mtls-app:APP_GUID [2].

This PR adds a new CREDHUB_USE_CF_INSTANCE_IDENTITY environment variable. When set to true it will configure CredHub to use the Instance Identity certificates, and all CredHub commands will be run using that mtls-app:APP_GUID role.

I think this has a lot of value in an automated, brokered CredHub like the one I'm working on in my credhub-service-broker [3].

This feature will only work if the buildpack is built to include a version of the CredHub CLI that supports using client certificates. I have a PR open for that [4].

[1] https://docs.cloudfoundry.org/devguide/deploy-apps/instance-identity.html
[2] https://github.com/cloudfoundry-incubator/credhub/blob/master/docs/authentication-identities.md
[3] https://github.com/46bit/credhub-service-broker
[4] cloudfoundry/credhub-cli#103

How to review

For now I'm interested in whether you'd merge this. :)

Cloud Foundry provides all apps with certificates containing their
identity, a system called Instance Identity [1]. You can use these
certificates to connect to CredHub using Mutual TLS, and when you do
you get the role `mtls-app:APP_GUID` [2].

This PR adds a new `CREDHUB_USE_CF_INSTANCE_IDENTITY` environment
variable. When set to true it will configure CredHub to use the
Instance Identity certificates, and all CredHub commands will be run
using that `mtls-app:APP_GUID` role.

I think this has a lot of value in an automated, brokered CredHub like
the one I'm working on in my `credhub-service-broker` [3].

This feature will only work if the buildpack is built to include a
version of the CredHub CLI that supports using client certificates.
I have a PR open for that [4].

[1] https://docs.cloudfoundry.org/devguide/deploy-apps/instance-identity.html
[2] https://github.com/cloudfoundry-incubator/credhub/blob/master/docs/authentication-identities.md
[3] https://github.com/46bit/credhub-service-broker
[4] cloudfoundry/credhub-cli#103
Copy link
Owner

@andy-paine andy-paine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely would accept this! I wanted to use instance certs in some way but the lack of CLI support and me not having thought as much about the user experience meant I left this as-is.

@@ -6,6 +6,11 @@
env_dir = ARGV[1]
file_dir = ARGV[2]

if ENV["CREDHUB_USE_CF_INSTANCE_IDENTITY"] == "true"
Copy link
Owner

@andy-paine andy-paine Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ENV["CREDHUB_USE_CF_INSTANCE_IDENTITY"] == "true"
if not ENV.key? 'CREDHUB_CLIENT' and ENV.key? 'CREDHUB_SECRET'

I think make this the default auth method since it is the only one that doesn't require any external data. This leaves it really clean when you are using cert auth since you just include CREDHUB_SERVER and CREDHUB_CA_CERT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants