]> granicus.if.org Git - pdns/commitdiff
auth: Deny cache flush, zone retrieve and notify if the API is RO
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 22 Aug 2017 09:48:07 +0000 (11:48 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 24 Nov 2017 09:44:17 +0000 (10:44 +0100)
(cherry picked from commit 64337a2fef53883a1962e36ae047b3a595951a42)

pdns/ws-auth.cc

index c1fb9fad1b659cc881af14512c5c8bb596d826cb..2380206ce367de23638bbcbdbfbb518271b8e5cc 100644 (file)
@@ -867,7 +867,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")
+  if(req->method != "PUT" || ::arg().mustDo("api-readonly"))
     throw HttpMethodNotAllowedException();
 
   UeberBackend B;
@@ -886,7 +886,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")
+  if(req->method != "PUT" || ::arg().mustDo("api-readonly"))
     throw HttpMethodNotAllowedException();
 
   UeberBackend B;
@@ -1198,7 +1198,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
 }
 
 void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) {
-  if(req->method != "PUT")
+  if(req->method != "PUT" || ::arg().mustDo("api-readonly"))
     throw HttpMethodNotAllowedException();
 
   DNSName canon = apiNameToDNSName(req->getvars["domain"]);