--- /dev/null
+[bug] fdupont
+ Implemented HTTP basic authentication for HA dedicated
+ listener, before such configuration was silently ignored.
+ (Gitlab #4599)
HAConfig::PeerConfig::PeerConfig()
: tls_context_(), name_(), url_(""), trust_anchor_(), cert_file_(),
- key_file_(), role_(STANDBY), auto_failover_(false), basic_auth_() {
+ key_file_(), role_(STANDBY), auto_failover_(false), basic_auth_(),
+ basic_auth_config_() {
}
void
#include <asiolink/crypto_tls.h>
#include <dhcpsrv/subnet.h>
#include <exceptions/exceptions.h>
-#include <http/basic_auth.h>
+#include <http/basic_auth_config.h>
#include <http/post_request_json.h>
#include <http/url.h>
#include <util/optional.h>
/// when credentials are specified.
void addBasicAuthHttpHeader(http::PostHttpRequestJsonPtr request) const;
+ /// @brief Returns non-const basic HTTP authentication configuration.
+ http::BasicHttpAuthConfigPtr& getBasicAuthConfig() {
+ return (basic_auth_config_);
+ }
+
+ /// @brief Returns const basic HTTP authentication configuration.
+ const http::BasicHttpAuthConfigPtr& getBasicAuthConfig() const {
+ return (basic_auth_config_);
+ }
+
/// @brief Server TLS context.
///
/// @note: if you make it protected or private please make
Role role_; ///< Server role.
bool auto_failover_; ///< Auto failover state.
http::BasicHttpAuthPtr basic_auth_; ///< Basic HTTP authentication.
+ http::BasicHttpAuthConfigPtr basic_auth_config_; ///< Basic HTTP authentication configuration.
};
/// @brief Pointer to the server's configuration.
}
password = getString(p, "basic-auth-password");
}
+ std::string password_file;
if (p->contains("basic-auth-password-file")) {
- std::string password_file =
- getString(p, "basic-auth-password-file");
+ password_file = getString(p, "basic-auth-password-file");
try {
password = util::file::getContent(password_file);
} catch (const std::exception& ex) {
user = getString(p, "basic-auth-user");
do_auth = true;
}
+ std::string user_file;
if (p->contains("basic-auth-user-file")) {
- std::string user_file =
- getString(p, "basic-auth-user-file");
+ user_file = getString(p, "basic-auth-user-file");
try {
user = util::file::getContent(user_file);
do_auth = true;
}
if (do_auth) {
BasicHttpAuthPtr& auth = cfg->getBasicAuth();
+ BasicHttpAuthConfigPtr& auth_config = cfg->getBasicAuthConfig();
try {
if (!user.empty()) {
// Validate the user id value.
auth.reset(new BasicHttpAuth(user, password));
+ auth_config.reset(new BasicHttpAuthConfig);
+ auth_config->add(user, user_file, password, password_file);
}
} catch (const std::exception& ex) {
isc_throw(dhcp::DhcpConfigError, ex.what() << " in peer '"
auto tls_context = config_->getThisServerConfig()->getTlsContext();
// Set the HTTP basic authentication.
- HttpAuthConfigPtr auth_config;
- // Wrong type: BasicHttpAuthPtr vs BasicHttpAuthConfigPtr
- // auth_config = config_->getThisServerConfig()->getBasicAuth();
+ HttpAuthConfigPtr auth_config =
+ config_->getThisServerConfig()->getBasicAuthConfig();
// Set the command filter when enabled.
std::unordered_set<std::string> command_accept_list;