Repository navigation
Add Azure Key Vault credential provider - #3081
thomastaylor312 wants to merge 5 commits into
Conversation
|
I'll be working on a PR for docs as well. Not sure if that need to be in place before this can be merged |
This is dependent on the [associated PR in Concourse](concourse/concourse#3081) being merged Signed-off-by: Taylor Thomas <[email protected]>
|
The testflight failure seems like a flake, but I am not familiar enough with the systems to be completely sure |
|
@thomastaylor312 I'll re-trigger I probably won't get a chance to look at this much today or over the weekend, but it looks really cool - thanks for working on it! And thanks for submitting docs too! |
This is just the basic scaffolding of all the methods and the client setup. It is not hooked up in any way Signed-off-by: Taylor Thomas <[email protected]>
This adds full credential provider support for Azure Key Vault. As of this commit, there are no tests, but tests will be added in the next commit Signed-off-by: Taylor Thomas <[email protected]>
This adds unit tests for all parts of the key vault code worth testing Signed-off-by: Taylor Thomas <[email protected]>
Signed-off-by: Taylor Thomas <[email protected]>
This also has a few changes found while writing the test and exports the `FakeReader` struct for use in the suite tests Signed-off-by: Taylor Thomas <[email protected]>
c67a519 to
c826e16
Compare
|
Rebased and pushed to fix merge conflict |
|
Hey, just checking again - I probably won't have time to review this until after 5.0 is out the door, since we're focusing on that right now. 🙂 It's been a long time since we've shipped so I'm holding off on any last-minute big features for now. |
|
@vito Thanks for the update! Just out of curiosity (and definitely not holding you to your answer), when would you expect this to go out if it does get accepted? Just curious so we can roughly plan around it |
|
@thomastaylor312 Once 5.0 is finally out I'd like to get back to a much more frequent release cadence. Something like 2 weeks between releases was typical before. So maybe mid-February? However disaster tends to happen after we sit on a release for too long, so I can't really provide a strong guarantee. 😛 |
|
Shockingly enough the 5.0 release has largely gone without incident, so I should be able to review this soon. Thanks for waiting! |
vito
left a comment
There was a problem hiding this comment.
Hey, thanks, this looks great! 👍 I left a few comments, mostly for minor things, though I had one security concern over how the paths are constructed.
|
|
||
| // ErrSecretNotFound is the error returned when a secret cannot be found by the | ||
| // reader | ||
| var ErrSecretNotFound = fmt.Errorf("secret not found") |
There was a problem hiding this comment.
Looks like this is unused? Probably 'cause Get just returns a nil, false, nil in this case anyway.
| // FakeReader is a wrapper that implements the SecretReader interface for | ||
| // testing. Each function can be set independently depending on the needs of | ||
| // the test | ||
| type FakeReader struct { |
There was a problem hiding this comment.
FWIW we typically use counterfeiter for this kind of thing - it's used like this:
// go:generate counterfeiter . InterfaceName
type MyInterface interface {
// ...
}and then go generate ./... will create fakes/fake_my_interface.go
we have a TODO to add this to the contributing docs (#3404)
There was a problem hiding this comment.
Oh, thanks for the pointer. I'll update that
| // Get returns the value of the given secret name, a bool if it was found, and | ||
| // an error if there was an issue fetching the secret | ||
| func (k *keyVaultReader) Get(name string) (string, bool, error) { | ||
| // Right now we aren't timing out, we may want to add a configurable option |
There was a problem hiding this comment.
Makes sense. I'm OK with this as-is for now. This may be something to consider generically rather than having each credential manager implement their own timeout flags.
Made a note for this here: https://github.com/concourse/rfcs/issues/5#issuecomment-472427713
| ) | ||
|
|
||
| func TestHealth(t *testing.T) { | ||
| t.Run("a working client should return good health", func(t *testing.T) { |
There was a problem hiding this comment.
We typically use ginkgo for tests but I won't split hairs. (More info: https://github.com/concourse/concourse/blob/master/CONTRIBUTING.md#testing-your-changes)
There was a problem hiding this comment.
Yeah, I wasn't sure on that because some of them (I think the vault one) didn't use ginkgo. I'll change it over so it doesn't diverge from the core project
| } | ||
|
|
||
| func (k *keyVault) path(parts ...string) string { | ||
| return fmt.Sprintf("%s-%s-%s", k.PathPrefix, k.TeamName, strings.Join(parts, "-")) |
There was a problem hiding this comment.
Is it possible to exploit this by putting a - in my team or pipeline name to access another team's credentials?
For example, concourse-foo-bar-x could either mean "team foo-bar, credential x" or "team foo, pipeline bar, credential x".
Is there another separator we could use?
To be honest we should probably just move credential manager configuration to the team-level (as mentioned in concourse/rfcs#5), but for now we have to watch out for this kind of thing.
There was a problem hiding this comment.
Unfortunately, Key Vault doesn't allow for other kinds of separators. Let me see what I can do to perform some validation because your concern is totally valid
There was a problem hiding this comment.
Dang, that's pretty strict. It doesn't even allow underscores. 👀
There was a problem hiding this comment.
So I am guessing the only way we can handle this is by not allowing teams with a dash in them for secret names. Basically we'd remove all dashes from the team name and end up with concourse-foobar-x for team foo-bar and concourse-foo-bar-x for "team foo, pipeline bar, credential x".
It is likely though that anyone using this will have a shared key vault anyway because there is no namespacing. Anyone who has edit access to the Key Vault will have access to any of the keys. If this is going to be a complete no-go from the security side of things, let me know. I think the other option would be to have each team with their own key vault (that the configured user for the credential provider has read access to) and we would change which key vault we are connecting to based on the team name
There was a problem hiding this comment.
Hmm, only problem then is teams foo-bar and foobar would end up sharing secrets. Granted, an operator would have had to knowingly create these ambiguous team names.
Well, here are some options I can think of:
- Implement per-team credential manager configuration first. I'd really like to get around to that, but I don't think I can fit it in to our day-to-day backlogs since we've already got a few top priorities ("spaces", runtime resiliency, API and internal architecture cleanups). We still need to create an actual RFC for this (concourse/rfcs#5 is actually an RF-RFC), but maybe that won't take too long if we keep them small in scope. Would this be something you'd be interested in contributing by any chance? It's definitely a scope creep, so if not, that's perfectly OK - just thought I'd ask. 🙂
- Support pre-configuring different key vaults per-team, as you suggested. This would achieve a decent middle ground for now, but it kind of feels like a stopgap solution - it'd be painful to configure and relatively inflexible (enabling it for new teams would require redeploying Concourse).
- Give up on multi-tenancy for this credential manager for now - forego the team and pipeline variable name scoping logic and just look up credentials by their exact name. This would at least make it obvious that it's one global scope, and it'd still be useful for folks that don't require multi-tenancy. We would just put a big warning on the docs saying this credential manager does not support scoped credentials.
I'm OK with either of these - the last idea is a little risky but I'm hoping by making the credential lookup rules so obviously different from the rest that users wouldn't mistakenly believe that it keeps teams away from each other's secrets.
There was a problem hiding this comment.
As a follow-up, I've started on an RFC for team-level credential manager configuration: concourse/rfcs#21
There was a problem hiding this comment.
So option 2 that you talked about shouldn't require a redeploy. The idea is that the same service principal would need to be granted access, so it should be able to establish a new connection with the given key vault.
I do like the per-team credential manager idea, but I might not have the cycles to do it (you know, day job and all 🙂). Let me see if I can make some time, otherwise I'll probably opt for the stop gap (option 2)
There was a problem hiding this comment.
Oh, though now that I am thinking about it more, that might not work... I believe all key vault names have to be unique and so someone with a team name like "devops" will quickly run into a naming collision. Let me see if I can find some cycles to do per-team credential management
There was a problem hiding this comment.
FWIW, because per-team credential management will be going through the RFC process, it may take a bit longer than you'd like compared to going with one of the short-term solutions here. More info on the whole process here: https://github.com/concourse/rfcs/blob/master/README.md
Any feedback on the RFC would be great in the meantime!
|
@thomastaylor312 now that #4600 has been merged, this opens up the possibility for Azure Key Vault to be used as a "pipeline-scoped-only" credential manager via |
|
At this point I haven't touched it in long enough and am not currently doing any concourse work. Feel free to close the PR if that is easier and I'll keep the branch around for anyone who may want to take it on |
Closing PR as per comment above. |
Adds credential provider for Azure Key Vault. This has all needed unit tests (I think) and has been manually validated as well