Skip to content

Commit

Permalink
influxdb authentication: Set authorization header manually
Browse files Browse the repository at this point in the history
influxdb 2.x has a compatibility v1 api that don't set the "WWW-Authenticate" header (violating rfc7235)
Setting the authorization header manually workarounds this issue

See: influxdata/influxdb#24219
  • Loading branch information
handymenny committed Apr 27, 2023
1 parent 0d5039c commit 3026677
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/Smokeping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4218,13 +4218,11 @@ sub load_cfg ($;$) {
);
if (defined $cfg->{'InfluxDB'}{'username'} && defined $cfg->{'InfluxDB'}{'password'}) {
do_log("DBG: Setting credentials for InfluxDB connection");
my $username = $cfg->{'InfluxDB'}{'username'};
my $password = $cfg->{'InfluxDB'}{'password'};
my $basicauth = MIME::Base64::encode("$username:$password", '');
my $ua = $influx->get_lwp_useragent();
$ua->credentials(
$cfg->{'InfluxDB'}{'host'} . ':' . $cfg->{'InfluxDB'}{'port'},
'InfluxDB',
$cfg->{'InfluxDB'}{'username'},
$cfg->{'InfluxDB'}{'password'}
);
$ua->default_header('Authorization', "Basic $basicauth");
}
}
$cfg->{__parser} = $parser;
Expand Down

0 comments on commit 3026677

Please sign in to comment.