-
Notifications
You must be signed in to change notification settings - Fork 71
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 for GSSAPI/Kerberos signed updates #30
Conversation
Hi @bodgit! This looks interesting and useful... thanks for working on it. Unfortunately it looks like the Do you think it's possible to support this functionality using a pure-Go Kerberos implementation? I see We've attempted to introduce CGo dependencies into providers before and found that it would require quite extensive updates to the release process which unfortunately we do not have the resources to do at this time due to other work. 😞 |
I wasn't sure if the CGo requirement was going to be an issue, makes sense. I did look initially at using jcmturner/gokrb5 as it was a pure-Go implementation, (I have jcmturner/gokrb5#65 open from when I explored using it). From memory it works fine for the initial part of negotiating the context between the client and server however it currently (or did, I should check again) lacks an implementation of the However that implementation lacks a lot of the Kerberos-specific functions which then requires that you run |
Not sure how I closed this. |
Any updates? |
@arnisoph I haven't had chance to revisit the pure-Go implementation, however the pivotal bit is the changes to the underlying DNS library; the main project maintainer seems to be ignoring the PR and insisting that I'm breaking backwards compatibility when I'm not and at least one other maintainer of the library seem to agree with me. I suspect my PR that is open there doesn't apply cleanly now however I'm in no rush to rebase it if it's just going to sit there and be ignored some more. I'm not going to drop this as it's still actively being used, albeit just a custom in-house build off of this branch but the more people who can voice support would be useful. |
We might need to maintain such a inhouse build, too. I'd like to prevent invoking the CLI tool nsupdate from TF.. |
I've finally managed to improve the https://github.com/jcmturner/gokrb5 library with the missing bits so there is now a pure Go implementation which works. I just need the outstanding PR merged to the https://github.com/miekg/dns library. |
b98a566
to
0a1b93a
Compare
This is actually ready for review, and hopefully merge. The code now uses a pure Go Kerberos/GSSAPI implementation and is also therefore more versatile. It can be used as in my original example which means it relies on the current user context, or you can explicitly configure it with a realm, username and either a password, or a keytab (keytab not supported on Windows): provider "dns" {
update {
server = "ns.example.com"
gssapi = true
realm = "EXAMPLE.COM"
username = "user"
password = "secret"
}
} or: provider "dns" {
update {
server = "ns.example.com"
gssapi = true
realm = "EXAMPLE.COM"
username = "user"
keytab = "/path/to/keytab"
}
} Now, the sticky bit is the maintainer of the underlying DNS library just ignored my PR and wouldn't engage in a discussion. To that end I've ended up embedding and extending enough of the library so there is a compatible |
@bodgit , is there any ETA on when this might be merged? |
@atkinson137 I need to fix up the handful of merge conflicts which have appeared in the meantime, however I don't have commit access to this repository so I'm/we're waiting on someone from Hashicorp to 👍 or 👎 this. I appreciate getting Terraform v0.12 ready has probably been taking up most of Hashicorp's time recently but there are a few issues and PR's that are just waiting for someone with commit privs. Sadly I don't think this provider gets as much love as say the AWS one, (happy to help with this!). |
5488a59
to
f285960
Compare
Right, should be current against master again now. |
@kmoe @apparentlymart any chance I could possibly get a review on this and the other two PR's please? They look scary but that's purely down to touching the |
@bodgit just wondering if you were able to address the wildcard DNS issue with the latest changes? Additionally wondering if the provider still requires a krb5.conf file or if there is opportunity to load the config from a variable? Either way thanks for keeping this effort going! |
@bhoriuchi It appears Windows doesn't support creating wildcard DNS entries using dynamic DNS updates. I've verified using a small piece of test code to send the wildcard update; it doesn't work against Windows but works fine against a Kerberos-enabled BIND. If I create a non-wildcard record it succeeds on both. I've also tried using My code (hopefully) honours all of the standard Kerberos environment variables so it will use the |
@bodgit Thank you for your saintly patience and the work you've put in to this PR. After some internal reshuffling at HashiCorp, this repository is now maintained by me. Since my team is responsible for more than 20 other repositories, this maintenance will be rather slow, especially for new features, since, as Martin indicates, our top priority is the stability and correctness of these very widely used providers. They are being monitoried for contributions, however, and priority is based on a number of factors including popularity measured in 👍 reactions. As mentioned in #118, I'd like to avoid a major version bump of this provider, so it's best if we continue supporting the (admittedly deprecated) HMAC-MD5 algorithm. Once that is added I think we can merge all three PRs at the same time. |
@kmoe I knew there was something I'd forgotten to mention in my comments, HMAC-MD5 should be supported still. The PR to the upstream DNS library I had merged allows you to plug in your own TSIG implementations so I just provide my own that still supports HMAC-MD5 as well as all of the other algorithms. I've added a test case to make sure it works however I'm having trouble getting Travis to actually run the tests; it looks like it has such a backlog of jobs to run that the tests for this repo never manage to make it to the front of the queue before they get cancelled after something like 5 or 6 hours. I've checked this morning and the backlog is still over 2,600 jobs with only ~ 240 running at any one time. I will periodically keep trying to schedule this and I'll squash the empty commits away once I get things to run. |
@bodgit Thanks for adding the MD5 test. There's an issue with Travis at the moment that I'll be investigating today. Unfortunate timing, as it was working last week. By the end of today, either we'll have Travis working again, or we'll start migrating onto our new CI system and I'll approve this PR after the tests pass locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge this once the GitHub Actions setup is complete. Certain acceptance tests aren't working yet, for reasons unrelated to this PR. Thanks for your patience!
If you need me to look at anything or rebase things, let me know. |
@bodgit I'd like to merge this soon despite the ongoing GitHub Actions problem (which is unrelated to this PR). Tests were all passing locally when I last checked, but I ran them again just now and get the following error:
Would you mind rebasing and taking a look at this? If I have time later today I'll investigate myself. |
Sure. Where's that external DNS server coming from though? If I do a reverse lookup it comes back as |
Switch to using our own Dockerfile. This creates three container images: * Kerberos KDC. This creates a new realm and two keytab files; one for BIND to use and another for a test user. * BIND DNS server. This has Kerberos configured but can be operated without. * User keytab. This exists purely to extract the keytab file out of the KDC container. The containers need to be created in sync with each other as the keytab files need to match up. The acceptance tests now build the containers from scratch each time, although the layers should be cached so repeat builds will be fast. The tests then run as before using the BIND container with a different /etc/named.conf volume mounted into place with either no TSIG configured, an HMAC-SHA256 TSIG key, or using Kerberos/GSS-TSIG. In the last case the KDC container is also created. For now, no Kerberos-enabled tests are actually run. The Travis build environment needed to be bumped from Trusty to Focal to get a new enough version of Docker to be able to use the buildx plugin, which is also installed.
This commit is the result of running the following: * go get github.com/bodgit/tsig * go mod tidy * go mod vendor
Runs three versions; password authentication, keytab authentication, and using an existing ticket/session.
Bizarre, I have no idea. All I did was pull your branch locally and run |
Ha, TIL! https://www.barefruit.com/
Well then... |
With 8.8.8.8:
Not sure why I'm getting this. Do the tests pass for you, @bodgit ? |
If you're running them locally, you might have to pop a |
There's something screwy in my install, if I try and run the tests on
|
Thank you, I had entirely neglected the The error you're getting seems to indicate you've somehow ended up with a nil client, despite (presumably) setting Were the tests passing for you previously? |
I think my error was caused by me having a 0.12.x Not having the |
Fabulous. After three years and a number of related and unrelated difficulties along the way, I'm now going to merge this PR. The new functionality will go out in today's v3.1.0 release. Thank you @bodgit for your great work on this PR and @apparentlymart for the thorough review. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
This PR adds support for performing DNS updates using GSSAPI/Kerberos which makes it possible to update zones on Windows servers that have the zone require "Secure only" updates, (BIND can also be configured to support this mechanism).
To configure the provider, you need something like:
Terraform needs to be run from a shell that has a valid Kerberos session which normally means having run
kinit
beforehand on Linux/Unix platforms. Current limitations are that it only supports using the credentials of the current shell running Terraform, you can't assume the identity of another user. This is mostly down to the fact I have yet to find a library for Go that both supports the necessary GSSAPI calls for doing the DNS exchange as well as the necessary Kerberos calls for creating a session as another user.All of the heavy lifting is done by https://github.com/bodgit/tsig and it uses GSSAPI on Linux/Unix using https://github.com/apcera/gssapi via a native shared library or on Windows using SSPI through https://github.com/alexbrainman/sspi which has a very similar API to GSSAPI.
I've marked it WIP as it's currently reliant on a pending PR (miekg/dns#626) for the http://github.com/miekg/dns package to add support for non-HMAC TSIG algorithms but I figured I'd put the changes out there for people to test.