mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-07 20:25:08 +02:00
Merge pull request #8314 from Icinga/feature/add-support-influxdb-basic-auth-7644
Add support Influxdb basic auth
This commit is contained in:
commit
6f33c2f90c
@ -1607,6 +1607,13 @@ object InfluxdbWriter "influxdb" {
|
||||
host = "127.0.0.1"
|
||||
port = 8086
|
||||
database = "icinga2"
|
||||
username = "icinga2"
|
||||
password = "icinga2"
|
||||
|
||||
basic_auth = {
|
||||
username = "icinga"
|
||||
password = "icinga"
|
||||
}
|
||||
|
||||
flush_threshold = 1024
|
||||
flush_interval = 10s
|
||||
@ -1636,6 +1643,7 @@ Configuration Attributes:
|
||||
database | String | **Required.** InfluxDB database name. Defaults to `icinga2`.
|
||||
username | String | **Optional.** InfluxDB user name. Defaults to `none`.
|
||||
password | String | **Optional.** InfluxDB user password. Defaults to `none`.
|
||||
basic\_auth | Dictionary | **Optional.** Username and password for HTTP basic authentication.
|
||||
ssl\_enable | Boolean | **Optional.** Whether to use a TLS stream. Defaults to `false`.
|
||||
ssl\_ca\_cert | String | **Optional.** Path to CA certificate to validate the remote host.
|
||||
ssl\_cert | String | **Optional.** Path to host certificate to present to the remote host for mutual verification.
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "base/perfdatavalue.hpp"
|
||||
#include "base/stream.hpp"
|
||||
#include "base/json.hpp"
|
||||
#include "base/base64.hpp"
|
||||
#include "base/networkstream.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "base/statsfunction.hpp"
|
||||
@ -504,6 +505,17 @@ void InfluxdbWriter::Flush()
|
||||
request.set(http::field::user_agent, "Icinga/" + Application::GetAppVersion());
|
||||
request.set(http::field::host, url->GetHost() + ":" + url->GetPort());
|
||||
|
||||
{
|
||||
Dictionary::Ptr basicAuth = GetBasicAuth();
|
||||
|
||||
if (basicAuth) {
|
||||
request.set(
|
||||
http::field::authorization,
|
||||
"Basic " + Base64::Encode(basicAuth->Get("username") + ":" + basicAuth->Get("password"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
request.body() = body;
|
||||
request.set(http::field::content_length, request.body().size());
|
||||
|
||||
|
@ -38,6 +38,7 @@ class InfluxdbWriter : ConfigObject
|
||||
[config] String ssl_key{
|
||||
default {{{ return ""; }}}
|
||||
};
|
||||
[config, no_user_view] Dictionary::Ptr basic_auth;
|
||||
[config, required] Dictionary::Ptr host_template {
|
||||
default {{{
|
||||
return new Dictionary({
|
||||
@ -91,6 +92,12 @@ validator InfluxdbWriter {
|
||||
String "*";
|
||||
};
|
||||
};
|
||||
Dictionary basic_auth {
|
||||
required username;
|
||||
String username;
|
||||
required password;
|
||||
String password;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user