Skip to content

Commit

Permalink
influxdb authentication: set authorization header manually (#365)
Browse files Browse the repository at this point in the history
* influxdb authentication: set authorization header manually

InfluxDB 2.x v1 (compatibility) api doesn't set the "WWW-Authenticate" header (violating rfc7235).

Work around this issue by manually setting the Authorization header.

See: influxdata/influxdb#24219
  • Loading branch information
handymenny authored Jun 14, 2023
1 parent 0d5039c commit ee258ed
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

- InfluxDB 2.x v1 (compatibility) api doesn't set the "WWW-Authenticate" header (violating rfc7235).
Work around this issue by manually setting the Authorization header @HandyMenny
- use actual link for form submission @michaelharo
- allow to enable/disable autorefresh from ui @Fantros
- make image responsive @HinataKato
Expand Down
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ requires 'IO::Pty';
requires 'LWP';
requires 'Authen::Radius';
requires 'Path::Tiny';
requires 'MIME::Base64';
requires 'InfluxDB::HTTP';
requires 'InfluxDB::LineProtocol';
# JSON::MaybeXS and Object::Result are required by InfluxDB::HTTP but were not
Expand Down
11 changes: 5 additions & 6 deletions lib/Smokeping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use Smokeping::Graphs;
use URI::Escape;
use Time::HiRes;
use Data::Dumper;
use MIME::Base64;
# optional dependencies
# will be imported in case InfluxDB host is configured
# InfluxDB::HTTP
Expand Down Expand Up @@ -4218,13 +4219,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 = encode_base64("$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 ee258ed

Please sign in to comment.