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

Rectify zones via the API #5779

Merged
merged 8 commits into from
Oct 18, 2017
Merged

Conversation

pieterlexis
Copy link
Contributor

Short description

This PR adds zone rectification to the API. Work done:

  • Move the pdnsutil rectification code to the DNSSECKeeper
  • Generate DNSSEC keys for a zone when "dnssec" is true in an API POST/PATCH for zones
  • Rectify DNSSEC zones after POST/PATCH when API-RECTIFY metadata is 1
  • Allow setting this metadata via the "api-rectify" param in a Zone object
  • Show "nsec3param" and "nsec3narrow" in Zone API responses
  • Add an "rrsets" request parameter for a zone to skip sending RRSets in the response (Closes API zone endpoint should support an 'rrset' parameter #5712)
  • Add checkNSEC3PARAM function
  • Add rectify endpoint in the API

This PR takes a lot of ideas and code from #3417 and subsequent development.

Closes #3417

Many thanks to Nils Wisiol (@nils-wisiol) for the initial implementation.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled and tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@pieterlexis pieterlexis added this to the auth-4.1.0 milestone Oct 6, 2017
@pieterlexis pieterlexis requested review from zeha and Habbie October 6, 2017 16:22
@nils-wisiol
Copy link
Contributor

@pieterlexis, thank you for completing this! 👍

@peterthomassen
Copy link
Contributor

@pieterlexis Does this also allow setting NSEC3 settings?

@pieterlexis
Copy link
Contributor Author

@pieterlexis Does this also allow setting NSEC3 settings?

yes

return false;
}

UeberBackend B("default");
Copy link
Collaborator

Choose a reason for hiding this comment

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

DNSSECKeeper is supposed to have an UeberBackend instance already, so can you reuse that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interestingly, re-using the UeberBackend in the DNSSECKeeper makes the bind-dnssec-both test fail because getSOAUncached() returns false for secure-delegated.dnssec-parent.com. Investigating

Copy link
Contributor Author

Choose a reason for hiding this comment

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

confirmed, reverting 1d7630f makes all the tests pass.

Copy link
Collaborator

@zeha zeha Oct 17, 2017

Choose a reason for hiding this comment

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

That sounds reaaaally bad. Like someone keeping a list() operation open or sth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, I think I got it. In pdnsutil.cc:1983 we create a DNSSECKeeper object without handing it an UeberBackend. So when rectifyZone (in pdnsutil) is called we indeed can not get a SOA from that dk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so this is a bug(ish) in pdnsutil, but it does mean that calling DNSSECKeeper::rectifyZone means we need the Ueber backend. Maybe it indeed makes more sense to move rectifyZone to the UeberBackend (but that has other pain points)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I have made a solution that uses the existing UeberBackend if it works and allocates a new one when needed. C++ wizards are welcome to make this better......


``dnssec``, ``nsec3narrow``, ``nsec3param``, ``presigned`` are not yet implemented.
``secure-zone`` and ``rectify-zone`` (if ``api_rectify`` is set to "1").
This also applies to newly created zones. If ``presigned`` is ``true``,
Copy link
Collaborator

Choose a reason for hiding this comment

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

the mismatch of 1 and true is quite ugly here. I think API consumers should not carry the burden of dealing with different truthiness values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I do make a bool out of, but it is wrongly documented

Copy link
Collaborator

Choose a reason for hiding this comment

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

the code below indeed confused me. please check whats actually there and i think boolifying it is a good idea (:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The POST/PUT and GET for api_rectify were not consistent. It is fully boolified on the API level in the upcoming push.

pdns/ws-auth.cc Outdated
if (k_algo != -1) {
int64_t id;
if (!dk.addKey(zonename, true, k_algo, id, k_size)) {
throw ApiException("No backend was able to secure '" + zonename.toString() + "', most likely because no DNSSEC"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This message is duplicated at least three times.

Also I can't say I like these super-long messages that suggest backend-specific config settings...

}
if (!dk.setNSEC3PARAM(zonename, ns3pr, boolFromJson(document, "nsec3narrow", false))) {
throw ApiException("NSEC3PARAMs provided for zone '" + zonename.toString() +
"' passed our basic sanity checks, but cannot be used with the current backend.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/current/hosting/?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe current is the better word here; "hosting" over-specifies the backend and suggests there is more than one backend at a time.

pdns/ws-auth.cc Outdated
if (!dk.rectifyZone(zonename, error_msg))
throw ApiException("Failed to rectify '" + zonename.toString() + "' " + error_msg);
}

di.backend->commitTransaction();
Copy link
Collaborator

Choose a reason for hiding this comment

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

dk.rectifyZone calls commitTransaction too, right? Maybe dk.rectifyZone shouldn't deal with backend lookups and transactions at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would mean that all callers are responsible for this? I would prefer dk.rectifyZone() to do some sanity checking and perform adding the ENTs in a safe way

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably. But it'd be great if the API could modify and rectify the zone in one TX, so no unrectified stuff is ever served by the DNS parts...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is a sexy idea......

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be implemented

@pieterlexis
Copy link
Contributor Author

@zeha I think the new commits will satisfy your comments?

@pieterlexis pieterlexis force-pushed the api-rectify-version-2 branch from 8018aba to b921754 Compare October 17, 2017 11:16
This commit takes a lot of ideas and code from PowerDNS#3417 and subsequent
development and implements the following things:

 - Generate DNSSEC keys for a zone when "dnssec" is true in an API
   POST/PATCH for zones
 - Rectify DNSSEC zones after POST/PATCH when API-RECTIFY metadata is 1
 - Allow setting this metadata via the "api-rectify" param in a Zone
   object
 - Shows "nsec3param" and "nsec3narrow" in Zone API responses
 - Adds an "rrsets" request parameter for a zone to skip sending RRSets
   in the response (Closes PowerDNS#5712)

Closes PowerDNS#3417

Many thanks to Nils Wisiol (@nils-wisiol) for the initial
implementation.
But use a full UeberBackend when needed.
This is added so the API can wrap an update to a zone's records *and*
DNSSEC info into a single transaction.
@pieterlexis pieterlexis force-pushed the api-rectify-version-2 branch from b921754 to 89a7e70 Compare October 17, 2017 14:43
@aerique aerique merged commit b7abf35 into PowerDNS:master Oct 18, 2017
@pieterlexis pieterlexis deleted the api-rectify-version-2 branch October 18, 2017 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants