]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3398] Made 1234 the default secret/password
authorFrancis Dupont <fdupont@isc.org>
Fri, 20 Dec 2024 15:48:44 +0000 (16:48 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 27 Jan 2025 14:05:11 +0000 (15:05 +0100)
27 files changed:
doc/examples/ddns/template.json
doc/examples/https/httpd2/kea-httpd2.conf
doc/examples/https/nginx/kea-nginx.conf
doc/examples/kea4/all-keys-netconf.json
doc/examples/kea4/all-keys.json
doc/examples/kea4/backends.json
doc/examples/kea4/config-backend.json
doc/examples/kea4/hooks-radius.json
doc/examples/kea4/mysql-reservations.json
doc/examples/kea4/pgsql-reservations.json
doc/examples/kea6/all-keys-netconf.json
doc/examples/kea6/all-keys.json
doc/examples/kea6/backends.json
doc/examples/kea6/config-backend.json
doc/examples/kea6/mysql-reservations.json
doc/examples/kea6/pgsql-reservations.json
doc/sphinx/arm/admin.rst
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
doc/sphinx/arm/ext-radius.rst
doc/sphinx/arm/hooks-ha.rst
doc/sphinx/arm/hooks-legal-log.rst
src/bin/keactrl/kea-dhcp4.conf.pre
src/bin/keactrl/kea-dhcp6.conf.pre
src/lib/cc/Makefile.am
src/lib/cc/default_credentials.cc [new file with mode: 0644]
src/lib/cc/default_credentials.h [new file with mode: 0644]

index c4da2508e5323816f1b3f0a0584f8697a6742374..cec9e3234b625268fb1b97cbef228f525618a937 100644 (file)
@@ -91,7 +91,7 @@
 //            "digest-bits" : 256,
 //            Minimum truncated length in bits.
 //            Default 0 (means truncation is forbidden).
-//            "secret" : "<shared secret value>"
+//            "secret" : "1234" (shared secret value)
 //        }
 //        ,
 //        {
index b138673c59c240f83433d3a2ab79c5eccc7dd0f3..f5c007078f65ef1ca242ef43b664fca3f5d659ef 100644 (file)
@@ -48,9 +48,9 @@
 #   openssl pkcs12 -export -in kea-client.crt -inkey kea-client.key \
 #           -out kea-client.p12
 #
-#   If the password is kea, curl command becomes:
+#   If the password is 1234, curl command becomes:
 #
-#   curl -k --cert kea-client.p12:kea -X POST \
+#   curl -k --cert kea-client.p12:1234 -X POST \
 #        -H Content-Type:application/json -d '{ "command": "list-commands" }' \
 #         https://kea.example.org/kea
 #
index cdbd7b35c6e4f4ad581c2c698720c675935a5829..9817fe18de5e34f0bfbe8e251006eabd2cf36705 100644 (file)
@@ -48,9 +48,9 @@
 #   openssl pkcs12 -export -in kea-client.crt -inkey kea-client.key \
 #           -out kea-client.p12
 #
-#   If the password is kea, curl command becomes:
+#   If the password is 1234, curl command becomes:
 #
-#   curl -k --cert kea-client.p12:kea -X POST \
+#   curl -k --cert kea-client.p12:1234 -X POST \
 #        -H Content-Type:application/json -d '{ "command": "list-commands" }' \
 #         https://kea.example.org
 #
index 528cc697b921737dc8761420132d5c3f01c02a9c..1b956edec8874a6ae10834b5905b4413c7209e39 100644 (file)
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 5432,
index 3d28d78953e1fd5edcfe6d13047a318b6d9a03ad..0582233e2c02557669f40d5a7087df9391419231 100644 (file)
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 5432,
index 86e716a788d441b978619e7d0eea848c0c5372ac..e5abb16544efe3d64de654be46bc80494841eba6 100644 (file)
@@ -38,7 +38,7 @@
 //      "host": "localhost",
 //      "port": 3306,
 //      "user": "keatest",
-//      "password": "secret1",
+//      "password": "1234",
 //      "reconnect-wait-time": 3000, // expressed in ms
 //      "max-reconnect-tries": 3,
 //      "on-fail": "stop-retry-exit",
@@ -66,7 +66,7 @@
 //      "host": "localhost",
 //      "port": 5432,
 //      "user": "keatest",
-//      "password": "secret1",
+//      "password": "1234",
 //      "reconnect-wait-time": 3000, // expressed in ms
 //      "max-reconnect-tries": 3,
 //      "on-fail": "stop-retry-exit",
index ded603ad91d2a69fc1d2e7dd1e9bc6317c0b6124..39267b2b6057190a4c12ff0018562515f74c98ae 100644 (file)
@@ -38,7 +38,7 @@
                 "max-reconnect-tries": 3,
                 "name": "kea",
                 "user": "kea",
-                "password": "kea",
+                "password": "1234",
                 "host": "localhost",
                 "port": 3306
             }
index ba51f531f8dba34e30cefc2d12d6333c89069529..099517012ec833dacd234a4e6727a255554917f9 100644 (file)
                          // These are parameters for the first (and only) access server
                          "name": "127.0.0.1",
                          "port": 1812,
-                         "secret": "secret"
+                         "secret": "1234"
                      }
                      // Additional access servers could be specified here
                  ],
                  "servers": [ {
                          "name": "127.0.0.1",
                          "port": 1813,
-                         "secret": "secret"
+                         "secret": "1234"
                      }
                 ]
              }
index 99cf078e682ece3fe3ab255074e2cb241014ecb4..26d9eee02742cc723d6fb04e84a546b207238a8d 100644 (file)
@@ -61,7 +61,7 @@
     "max-reconnect-tries": 3,
     "name": "keatest",
     "user": "keatest",
-    "password": "keatest",
+    "password": "1234",
     "host": "localhost",
     "port": 3306,
     "trust-anchor": "my-ca",
index 2f94a0fc07495314cbc58978c5636d76f162d15a..94b190419267ed78210ec18791d3abeb0da4d8de 100644 (file)
@@ -63,7 +63,7 @@
        "max-reconnect-tries": 3,
        "name": "keatest",
        "user": "keatest",
-       "password": "keatest",
+       "password": "1234",
        "host": "localhost"
     }
   ],
index 8c716808c205c0b611595220ef1cbb53dd732bf9..8f812e0f5b784a09e8880041e098b4b496e45dc2 100644 (file)
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 5432,
index 2b93426b2b9211ccbadc28479afda48073897c76..bb6842ab4978f4a8b4b60b58f956e488976b0d53 100644 (file)
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "host": "localhost",
 
                 // Database password.
-                "password": "keatest",
+                "password": "1234",
 
                 // Port on which the database is available.
                 "port": 5432,
index 31ab9697f1599a2f3bb84daee18358a5344f0997..097d37c394f90ea6ffce06cae73fa47d0965fa47 100644 (file)
@@ -38,7 +38,7 @@
 //      "host": "localhost",
 //      "port": 3306,
 //      "user": "keatest",
-//      "password": "secret1",
+//      "password": "1234",
 //      "reconnect-wait-time": 3000, // expressed in ms
 //      "max-reconnect-tries": 3,
 //      "on-fail": "stop-retry-exit",
@@ -66,7 +66,7 @@
 //      "host": "localhost",
 //      "port": 5432,
 //      "user": "keatest",
-//      "password": "secret1",
+//      "password": "1234",
 //      "reconnect-wait-time": 3000, // expressed in ms
 //      "max-reconnect-tries": 3,
 //      "on-fail": "stop-retry-exit",
index 5ec2efd0362582519ee5f4d0ff5a1d329530a3c0..2fc33b7927d7ce3fbb4cc67c5d9caa77ab2f3e1e 100644 (file)
@@ -38,7 +38,7 @@
                 "max-reconnect-tries": 3,
                 "name": "kea",
                 "user": "kea",
-                "password": "kea",
+                "password": "1234",
                 "host": "localhost",
                 "port": 3306
             }
index a6b09afe108e508e7d63c1ec6b456735f8c47cd7..b83b9c003c0052fe7d81b518a5d65633a7d5c7a3 100644 (file)
@@ -48,7 +48,7 @@
     "max-reconnect-tries": 3,
     "name": "keatest",
     "user": "keatest",
-    "password": "keatest",
+    "password": "1234",
     "host": "localhost",
     "port": 3306,
     "readonly": true,
index 0910f2f3c02a006a06dd1ecbe7334be4cf434fb6..d2987caeeb90c0e311ea22efc83be0e3280d0054 100644 (file)
@@ -50,7 +50,7 @@
        "max-reconnect-tries": 3,
        "name": "keatest",
        "user": "keatest",
-       "password": "keatest",
+       "password": "1234",
        "host": "localhost"
     }
   ],
index 7acb070e221a9fa405d6b667a0d591ab384e0ddb..8c1676ca6c7f17d77124df24fba6df13198a8ac2 100644 (file)
@@ -246,7 +246,7 @@ To create the database:
 
    .. code-block:: mysql
 
-      mysql> CREATE USER 'user-name'@'localhost' IDENTIFIED BY 'password';
+      mysql> CREATE USER 'user-name'@'localhost' IDENTIFIED BY '1234';
       mysql> GRANT ALL ON database-name.* TO 'user-name'@'localhost';
 
    (``user-name`` and ``password`` are the user ID and password used to
@@ -485,7 +485,7 @@ which the servers will access it. A number of steps are required:
 
    .. code-block:: psql
 
-      postgres=# CREATE USER user-name WITH PASSWORD 'password';
+      postgres=# CREATE USER user-name WITH PASSWORD '1234';
       CREATE ROLE
       postgres=# GRANT ALL PRIVILEGES ON DATABASE database-name TO user-name;
       GRANT
index 868a5c99befc92dda3c260fceb61888cda71d3b8..ff90fbbeb2fea06a66a86e76ac0f3beb9a19e8b4 100644 (file)
@@ -601,7 +601,7 @@ access the database should be set:
    "Dhcp4": {
        "lease-database": {
            "user": "user-name",
-           "password": "password",
+           "password": "1234",
            ...
        },
        ...
@@ -708,7 +708,7 @@ connection to MySQL:
            "type": "mysql",
            "name": "kea",
            "user": "kea",
-           "password": "secret123",
+           "password": "1234",
            "host": "localhost",
            "port": 3306
        }
@@ -858,7 +858,7 @@ access the database should be set:
    "Dhcp4": {
        "hosts-database": {
            "user": "user-name",
-           "password": "password",
+           "password": "1234",
            ...
        },
        ...
@@ -8532,7 +8532,7 @@ database:
                        "type": "mysql",
                        "name": "kea",
                        "user": "kea",
-                       "password": "kea",
+                       "password": "1234",
                        "host": "192.0.2.1",
                        "port": 3302
                    }
@@ -8563,7 +8563,7 @@ The following snippet illustrates the use of a PostgreSQL database:
                        "type": "postgresql",
                        "name": "kea",
                        "user": "kea",
-                       "password": "kea",
+                       "password": "1234",
                        "host": "192.0.2.1",
                        "port": 3302
                    }
index 70fe913bdbe1fa55f7a36cf569a8515c0a79d0ae..6eebcd3f97c52a53740cf1f1b9f7d41eb794f4bb 100644 (file)
@@ -557,7 +557,7 @@ access the database should be set:
    "Dhcp6": {
        "lease-database": {
            "user": "user-name",
-           "password": "password",
+           "password": "1234",
            ...
        },
        ...
@@ -664,7 +664,7 @@ connection to MySQL:
            "type": "mysql",
            "name": "kea",
            "user": "kea",
-           "password": "secret123",
+           "password": "1234",
            "host": "localhost",
            "port": 3306
        }
@@ -814,7 +814,7 @@ access the database should be set:
    "Dhcp6": {
        "hosts-database": {
            "user": "user-name",
-           "password": "password",
+           "password": "1234",
            ...
        },
        ...
@@ -8273,7 +8273,7 @@ database:
                        "type": "mysql",
                        "name": "kea",
                        "user": "kea",
-                       "password": "kea",
+                       "password": "1234",
                        "host": "2001:db8:1::1",
                        "port": 3302
                    }
@@ -8304,7 +8304,7 @@ The following snippet illustrates the use of a PostgreSQL database:
                        "type": "postgresql",
                        "name": "kea",
                        "user": "kea",
-                       "password": "kea",
+                       "password": "1234",
                        "host": "2001:db8:1::1",
                        "port": 3302
                    }
index 90d73b91899661041ccc0c2b56e8d72049a2a14d..7e4d038a74b8bbeed3efd65df526b140cb64c4ae 100644 (file)
@@ -242,7 +242,7 @@ At the service level, three sections can be configured:
   The value ``0`` means no limit; ``64`` is a recommended setting.
 
 For example, to specify a single access server available on localhost
-that uses ``"xyz123"`` as a secret, and tell Kea to send three additional
+that uses ``"1234"`` as a secret, and tell Kea to send three additional
 attributes (``User-Password``, ``Connect-Info``, and ``Configuration-Token``),
 the following snippet could be used:
 
@@ -261,7 +261,7 @@ the following snippet could be used:
               // These are parameters for the first (and only) access server
               "name": "127.0.0.1",
               "port": 1812,
-              "secret": "xyz123"
+              "secret": "1234"
             }
           // Additional access servers could be specified here.
           ],
@@ -303,7 +303,7 @@ the following snippet could be used:
               // These are parameters for the first (and only) accounting server
               "name": "127.0.0.1",
               "port": 1813,
-              "secret": "sekret"
+              "secret": "1234"
             }
             // Additional accounting servers could be specified here.
           ]
index 959c44596b7b45828c7fa6d8dc2c191a105bca5e..d6eb3a35f577e54c1a51cd7e5c31df7d359f8c18 100644 (file)
@@ -700,7 +700,7 @@ only difference that ``this-server-name`` should be set to "server2" and
                        "url": "http://192.168.56.99:8000/",
                        "role": "backup",
                        "basic-auth-user": "foo",
-                       "basic-auth-password": "bar",
+                       "basic-auth-password": "1234",
                        "auto-failover": false
                    }]
                }]
@@ -945,7 +945,7 @@ other words, if the query would normally be processed by ``server2`` but this
 server is not available, ``server1`` allocates the lease from the pool of
 "192.0.3.200 - 192.0.3.250". The Kea control agent in front of ``server3``
 requires basic HTTP authentication, and authorizes the user ID "foo" with the
-password "bar".
+password "1234".
 
 .. note::
 
@@ -1096,7 +1096,7 @@ The following is an example configuration of the primary server in a
                        "name": "server3",
                        "url": "http://192.168.56.99:8000/",
                        "basic-auth-user": "foo",
-                       "basic-auth-password": "bar",
+                       "basic-auth-password": "1234",
                        "role": "backup",
                        "auto-failover": false
                    }]
@@ -1175,7 +1175,7 @@ The following is an example configuration file for the primary server in a
                        "name": "server3",
                        "url": "http://192.168.56.99:8000/",
                        "basic-auth-user": "foo",
-                       "basic-auth-password": "bar",
+                       "basic-auth-password": "1234",
                        "role": "backup"
                    }]
                }]
index 1b2a3dd4bccedfd1236418727b11cbeebdec23ff..5da969d94df79cef4da0dce05b7055282285fcb6 100644 (file)
@@ -240,7 +240,7 @@ Additional parameters for the database connection can be specified, e.g:
             "library": "/usr/local/lib/kea/hooks/libdhcp_legal_log.so",
             "parameters": {
               "name": "database-name",
-              "password": "passwd",
+              "password": "1234",
               "type": "mysql",
               "user": "user-name"
             }
@@ -478,7 +478,7 @@ Examples:
             "library": "/usr/local/lib/kea/hooks/libdhcp_legal_log.so",
             "parameters": {
               "name": "database-name",
-              "password": "passwd",
+              "password": "1234",
               "type": "mysql",
               "user": "user-name",
               "request-parser-format": "'log entry' + 0x0a + 'same log entry'",
@@ -803,7 +803,7 @@ Examples:
             "library": "/usr/local/lib/kea/hooks/libdhcp_legal_log.so",
             "parameters": {
               "name": "database-name",
-              "password": "passwd",
+              "password": "1234",
               "type": "mysql",
               "user": "user-name",
               "request-parser-format": "'log entry' + 0x0a + 'same log entry'",
@@ -1061,7 +1061,7 @@ tools may be used, for example, to dump the logs table from a MYSQL database:
 
 ::
 
-   $ mysql --user keatest --password keatest -e "select * from logs;"
+   $ mysql --user keatest --password 1234 -e "select * from logs;"
    +---------------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+----+
    | timestamp           | address      | log                                                                                                                                                             | id |
    +---------------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+----+
index 44f811b952c8fa1a428a5c99797535c40fb82bdb..aced2a5261856e678a75e674d748b7a65e4ee601 100644 (file)
@@ -73,7 +73,7 @@
     //     "type": "mysql",
     //     "name": "kea",
     //     "user": "kea",
-    //     "password": "kea",
+    //     "password": "1234",
     //     "host": "localhost",
     //     "port": 3306
     // },
index d827b759b80ce361f635290f126c495280ee7a11..d043489b98f854f44fd8ecdc8772bba562e350d3 100644 (file)
@@ -67,7 +67,7 @@
     //     "type": "mysql",
     //     "name": "kea",
     //     "user": "kea",
-    //     "password": "kea",
+    //     "password": "1234",
     //     "host": "localhost",
     //     "port": 3306
     // },
index b3c1b5a858957a45436d4442a67cb52c0c0ff748..085dddb978dc3a7a77fc297ac60455846c457258 100644 (file)
@@ -10,6 +10,7 @@ libkea_cc_la_SOURCES += data.cc data.h
 libkea_cc_la_SOURCES += element_value.h
 libkea_cc_la_SOURCES += cfg_to_element.h dhcp_config_error.h
 libkea_cc_la_SOURCES += command_interpreter.cc command_interpreter.h
+libkea_cc_la_SOURCES += default_credentials.cc default_credentials.h
 libkea_cc_la_SOURCES += json_feed.cc json_feed.h
 libkea_cc_la_SOURCES += server_tag.cc server_tag.h
 libkea_cc_la_SOURCES += simple_parser.cc simple_parser.h
@@ -31,6 +32,7 @@ libkea_cc_include_HEADERS = \
        cfg_to_element.h \
        command_interpreter.h \
        data.h \
+       default_credentials.h \
        dhcp_config_error.h \
        element_value.h \
        json_feed.h \
diff --git a/src/lib/cc/default_credentials.cc b/src/lib/cc/default_credentials.cc
new file mode 100644 (file)
index 0000000..327f072
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+#include <cc/default_credentials.h>
+
+namespace isc {
+namespace data {
+
+const std::list<std::string> DefaultCredentials::DEFAULT_CREDENTIALS = {
+#ifndef IGNORE_KEA_DEFAULT_CREDENTIALS
+    "1234", "*****"
+#endif
+#ifdef EXTRA_KEA_DEFAULT_CREDENTIALS
+    EXTRA_KEA_DEFAULT_CREDENTIALS
+#endif
+};
+
+void DefaultCredentials::check(const std::string& value) {
+    for (auto const& cred : DEFAULT_CREDENTIALS) {
+        if (value == cred) {
+            isc_throw(DefaultCredential,
+                      "illegal use of a default value as credential");
+        }
+    }
+}
+
+}  // end of isc::dhcp namespace
+}  // end of isc namespace
diff --git a/src/lib/cc/default_credentials.h b/src/lib/cc/default_credentials.h
new file mode 100644 (file)
index 0000000..ade6fa5
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef DEFAULT_CREDENTIALS_H
+#define DEFAULT_CREDENTIALS_H
+
+#include <exceptions/exceptions.h>
+#include <list>
+#include <string>
+
+namespace isc {
+namespace data {
+
+/// @brief Exception thrown on attempt to use a default credential.
+class DefaultCredential : public Exception {
+public:
+    DefaultCredential(const char* file, size_t line, const char* what) :
+        isc::Exception(file, line, what) { }
+};
+
+/// @brief Base class for default credentials.
+struct DefaultCredentials {
+    /// @brief Default credentials.
+    ///
+    /// @note Using a list as there are only two default credentials.
+    static const std::list<std::string> DEFAULT_CREDENTIALS;
+
+    /// @brief Check if the value is a default credential.
+    ///
+    /// @param value The value to check.
+    /// @throw DefaultCredential if the value is in default credentials.
+    static void check(const std::string& value);
+};
+
+} // end of isc::dhcp namespace
+} // end of isc namespace
+
+
+#endif // DEFAULT_CREDENTIALS_H