]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Implement pdnsutil hash-password
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 30 Mar 2021 15:57:11 +0000 (17:57 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 16 Sep 2021 12:12:27 +0000 (14:12 +0200)
docs/manpages/pdnsutil.1.rst
pdns/pdnsutil.cc

index 9649979042feed3359e9679c009e1c0978856e44..2e141cd8d16ded5a86ce24d9e98e344ccf7a8342 100644 (file)
@@ -189,6 +189,10 @@ edit-zone *ZONE*
     **EDITOR** is empty, *pdnsutil* falls back to using *editor*.
 get-meta *ZONE* [*ATTRIBUTE*]...
     Get zone metadata. If no *ATTRIBUTE* given, lists all known.
+hash-password *PASSWORD*
+    This convenience command returns a hashed and salted version of the
+    password passed in parameter, for use as a webserver password or
+    api key.
 hash-zone-record *ZONE* *RNAME*
     This convenience command hashes the name *RNAME* according to the
     NSEC3 settings of *ZONE*. Refuses to hash for zones with no NSEC3
index de5503f37d35f99c9575eff83e373f0d96adbb69..4c73ff07e609c729daa3f73b4389d231cf91e85d 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <fcntl.h>
 
+#include "credentials.hh"
 #include "dnsseckeeper.hh"
 #include "dnssecinfra.hh"
 #include "statbag.hh"
@@ -2331,6 +2332,7 @@ try
     cout<<"generate-zone-key {zsk|ksk} [ALGORITHM] [BITS]"<<endl;
     cout<<"                                   Generate a ZSK or KSK to stdout with specified ALGORITHM and BITS"<<endl;
     cout<<"get-meta ZONE [KIND ...]           Get zone metadata. If no KIND given, lists all known"<<endl;
+    cout<<"hash-password PASSWORD             Take a plaintext password or api key and output a hashed and salted version"<<endl;
     cout<<"hash-zone-record ZONE RNAME        Calculate the NSEC3 hash for RNAME in ZONE"<<endl;
 #ifdef HAVE_P11KIT1
     cout<<"hsm assign ZONE ALGORITHM {ksk|zsk} MODULE SLOT PIN LABEL"<<endl<<
@@ -3071,6 +3073,14 @@ try
     }
     return 0;
   }
+  else if(cmds.at(0) == "hash-password") {
+    if (cmds.size() < 2) {
+      cerr<<"Syntax: pdnsutil hash-password PASSWORD"<<endl;
+      return 0;
+    }
+    cout<<hashPassword(cmds.at(1))<<endl;
+    return 0;
+  }
   else if (cmds.at(0) == "hash-zone-record") {
     if(cmds.size() < 3) {
       cerr<<"Syntax: pdnsutil hash-zone-record ZONE RNAME"<<endl;