]> granicus.if.org Git - pdns/commitdiff
Drop api-readonly configuration setting
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 10 Aug 2018 13:15:55 +0000 (15:15 +0200)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 10 Aug 2018 13:15:55 +0000 (15:15 +0200)
pdns/common_startup.cc
pdns/pdns_recursor.cc
pdns/recursordist/docs/settings.rst
pdns/ws-auth.cc
pdns/ws-recursor.cc
regression-tests.recursor/config.sh

index 786a212a72a5e11a8b881c3f624847d95259a94d..cb21048352276378193887c16a18c9cfecfd8ab3 100644 (file)
@@ -94,7 +94,6 @@ void declareArguments()
   ::arg().setSwitch("api", "Enable/disable the REST API (including HTTP listener)")="no";
   ::arg().set("api-key", "Static pre-shared authentication key for access to the REST API")="";
   ::arg().set("api-logfile", "Location of the server logfile (used by the REST API)")="/var/log/pdns.log";
-  ::arg().setSwitch("api-readonly", "Disallow data modification through the REST API when set")="no";
   ::arg().setSwitch("dname-processing", "If we should support DNAME records")="no";
 
   ::arg().setCmd("help","Provide a helpful message");
index d854a7f0ee5958f665560e1498e6dbed31bf4bfa..6ce03ec55be69087d64906e3ac5721b44588cd1b 100644 (file)
@@ -3921,7 +3921,6 @@ int main(int argc, char **argv)
     ::arg().set("api-config-dir", "Directory where REST API stores config and zones") = "";
     ::arg().set("api-key", "Static pre-shared authentication key for access to the REST API") = "";
     ::arg().set("api-logfile", "Location of the server logfile (used by the REST API)") = "/var/log/pdns.log";
-    ::arg().set("api-readonly", "Disallow data modification through the REST API when set") = "no";
     ::arg().setSwitch("webserver", "Start a webserver (for REST API)") = "no";
     ::arg().set("webserver-address", "IP Address of webserver to listen on") = "127.0.0.1";
     ::arg().set("webserver-port", "Port of webserver to listen on") = "8082";
@@ -4055,8 +4054,8 @@ int main(int argc, char **argv)
 
     ::arg().parse(argc,argv);
 
-    if( !::arg()["chroot"].empty() && !::arg()["api-config-dir"].empty() && !::arg().mustDo("api-readonly") )  {
-      g_log<<Logger::Error<<"Using chroot and a writable API is not possible"<<endl;
+    if( !::arg()["chroot"].empty() && !::arg()["api-config-dir"].empty() ) {
+      g_log<<Logger::Error<<"Using chroot and enabling the API is not possible"<<endl;
       exit(EXIT_FAILURE);
     }
 
index caeb21f1eaa8d11d2e8d86ed88b3ee6e9c069617..537c157152b9d36896b31a2e7a96c89f87431687 100644 (file)
@@ -81,6 +81,7 @@ Static pre-shared authentication key for access to the REST API.
 ``api-readonly``
 ----------------
 .. versionadded:: 4.0.0
+.. versionremoved:: 4.2.0
 
 -  Boolean
 -  Default: no
index 03d45bc2f151263a21f0ee0624aa45688cd2925a..509f6e2bc05961eb7ddc845e1963fbe9ca29232f 100644 (file)
@@ -792,7 +792,7 @@ static void apiZoneMetadata(HttpRequest* req, HttpResponse *resp) {
     }
 
     resp->setBody(document);
-  } else if (req->method == "POST" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "POST") {
     auto document = req->json();
     string kind;
     vector<string> entries;
@@ -875,7 +875,7 @@ static void apiZoneMetadataKind(HttpRequest* req, HttpResponse* resp) {
 
     document["metadata"] = entries;
     resp->setBody(document);
-  } else if (req->method == "PUT" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "PUT") {
     auto document = req->json();
 
     if (!isValidMetadataKind(kind, false))
@@ -902,7 +902,7 @@ static void apiZoneMetadataKind(HttpRequest* req, HttpResponse* resp) {
     };
 
     resp->setBody(key);
-  } else if (req->method == "DELETE" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "DELETE") {
     if (!isValidMetadataKind(kind, false))
       throw ApiException("Unsupported metadata kind '" + kind + "'");
 
@@ -1182,13 +1182,13 @@ static void apiZoneCryptokeys(HttpRequest *req, HttpResponse *resp) {
 
   if (req->method == "GET") {
     apiZoneCryptokeysGET(zonename, inquireKeyId, resp, &dk);
-  } else if (req->method == "DELETE" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "DELETE") {
     if (inquireKeyId == -1)
       throw HttpBadRequestException();
     apiZoneCryptokeysDELETE(zonename, inquireKeyId, req, resp, &dk);
-  } else if (req->method == "POST" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "POST") {
     apiZoneCryptokeysPOST(zonename, req, resp, &dk);
-  } else if (req->method == "PUT" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "PUT") {
     if (inquireKeyId == -1)
       throw HttpBadRequestException();
     apiZoneCryptokeysPUT(zonename, inquireKeyId, req, resp, &dk);
@@ -1246,7 +1246,7 @@ static void checkDuplicateRecords(vector<DNSResourceRecord>& records) {
 static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
   UeberBackend B;
   DNSSECKeeper dk(&B);
-  if (req->method == "POST" && !::arg().mustDo("api-readonly")) {
+  if (req->method == "POST") {
     DomainInfo di;
     auto document = req->json();
     DNSName zonename = apiNameToDNSName(stringFromJson(document, "name"));
@@ -1432,7 +1432,7 @@ static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp) {
     throw HttpNotFoundException();
   }
 
-  if(req->method == "PUT" && !::arg().mustDo("api-readonly")) {
+  if(req->method == "PUT") {
     // update domain settings
 
     updateDomainSettingsFromDocument(B, di, zonename, req->json());
@@ -1441,7 +1441,7 @@ static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp) {
     resp->status = 204; // No Content, but indicate success
     return;
   }
-  else if(req->method == "DELETE" && !::arg().mustDo("api-readonly")) {
+  else if(req->method == "DELETE") {
     // delete domain
     if(!di.backend->deleteDomain(zonename))
       throw ApiException("Deleting domain '"+zonename.toString()+"' failed: backend delete failed/unsupported");
@@ -1450,7 +1450,7 @@ static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp) {
     resp->body = "";
     resp->status = 204; // No Content: declare that the zone is gone now
     return;
-  } else if (req->method == "PATCH" && !::arg().mustDo("api-readonly")) {
+  } else if (req->method == "PATCH") {
     patchZone(req, resp);
     return;
   } else if (req->method == "GET") {
@@ -1501,7 +1501,7 @@ static void apiServerZoneExport(HttpRequest* req, HttpResponse* resp) {
 static void apiServerZoneAxfrRetrieve(HttpRequest* req, HttpResponse* resp) {
   DNSName zonename = apiZoneIdToName(req->parameters["id"]);
 
-  if(req->method != "PUT" || ::arg().mustDo("api-readonly"))
+  if(req->method != "PUT")
     throw HttpMethodNotAllowedException();
 
   UeberBackend B;
@@ -1521,7 +1521,7 @@ static void apiServerZoneAxfrRetrieve(HttpRequest* req, HttpResponse* resp) {
 static void apiServerZoneNotify(HttpRequest* req, HttpResponse* resp) {
   DNSName zonename = apiZoneIdToName(req->parameters["id"]);
 
-  if(req->method != "PUT" || ::arg().mustDo("api-readonly"))
+  if(req->method != "PUT")
     throw HttpMethodNotAllowedException();
 
   UeberBackend B;
@@ -1886,7 +1886,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
 }
 
 void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) {
-  if(req->method != "PUT" || ::arg().mustDo("api-readonly"))
+  if(req->method != "PUT")
     throw HttpMethodNotAllowedException();
 
   DNSName canon = apiNameToDNSName(req->getvars["domain"]);
index 4cea7898d99580658f34cd993173b24c9b8cdd64..e3a5e8024309c9cd51f526512f2a8b8d574ea22e 100644 (file)
@@ -70,7 +70,7 @@ static void apiWriteConfigFile(const string& filebasename, const string& content
 
 static void apiServerConfigAllowFrom(HttpRequest* req, HttpResponse* resp)
 {
-  if (req->method == "PUT" && !::arg().mustDo("api-readonly")) {
+  if (req->method == "PUT") {
     Json document = req->json();
 
     auto jlist = document["value"];
@@ -248,7 +248,7 @@ static bool doDeleteZone(const DNSName& zonename)
 
 static void apiServerZones(HttpRequest* req, HttpResponse* resp)
 {
-  if (req->method == "POST" && !::arg().mustDo("api-readonly")) {
+  if (req->method == "POST") {
     if (::arg()["api-config-dir"].empty()) {
       throw ApiException("Config Option \"api-config-dir\" must be set");
     }
@@ -300,7 +300,7 @@ static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp)
   if (iter == SyncRes::t_sstorage.domainmap->end())
     throw ApiException("Could not find domain '"+zonename.toLogString()+"'");
 
-  if(req->method == "PUT" && !::arg().mustDo("api-readonly")) {
+  if(req->method == "PUT") {
     Json document = req->json();
 
     doDeleteZone(zonename);
@@ -309,7 +309,7 @@ static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp)
     resp->body = "";
     resp->status = 204; // No Content, but indicate success
   }
-  else if(req->method == "DELETE" && !::arg().mustDo("api-readonly")) {
+  else if(req->method == "DELETE") {
     if (!doDeleteZone(zonename)) {
       throw ApiException("Deleting domain failed");
     }
index 6d2dbc05aec9ae2ba9ba85d5d30f578a64243db7..da2b47276e5fb1699c293618aa0a4c64e5cce8f1 100755 (executable)
@@ -559,7 +559,6 @@ EOF
 cat > recursor-service/recursor.conf <<EOF
 webserver=yes
 api-key=secret
-api-readonly=yes
 forward-zones-file=$(pwd)/recursor-service/forward-zones-file
 
 socket-dir=/tmp/recursor-service