Merge pull request #9680 from JimMoen/fix-influxdb-api

fix(influxdb): authentication is not required for influxdb v1 api
This commit is contained in:
JimMoen 2023-01-17 10:58:53 +08:00 committed by GitHub
commit 050d245fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 9 deletions

View File

@ -0,0 +1 @@
Fix the problem that username and password authentication is mandatory in Influxdb v1 write API.

View File

@ -0,0 +1 @@
修复 InfluxDB v1 桥接写入 API 配置中强制需要用户名密码认证的问题。

View File

@ -278,19 +278,18 @@ client_config(
] ++ protocol_config(Config). ] ++ protocol_config(Config).
%% api v1 config %% api v1 config
protocol_config(#{ protocol_config(
username := Username, #{
password := Password,
database := DB, database := DB,
ssl := SSL ssl := SSL
}) -> } = Config
) ->
[ [
{protocol, http}, {protocol, http},
{version, v1}, {version, v1},
{username, str(Username)},
{password, str(Password)},
{database, str(DB)} {database, str(DB)}
] ++ ssl_config(SSL); ] ++ username(Config) ++
password(Config) ++ ssl_config(SSL);
%% api v2 config %% api v2 config
protocol_config(#{ protocol_config(#{
bucket := Bucket, bucket := Bucket,
@ -321,6 +320,16 @@ ssl_config(SSL = #{enable := true}) ->
{transport, ssl} {transport, ssl}
] ++ maps:to_list(maps:remove(enable, SSL)). ] ++ maps:to_list(maps:remove(enable, SSL)).
username(#{username := Username}) ->
[{username, str(Username)}];
username(_) ->
[].
password(#{password := Password}) ->
[{password, str(Password)}];
password(_) ->
[].
%% ------------------------------------------------------------------------------------------------- %% -------------------------------------------------------------------------------------------------
%% Query %% Query
do_query(InstId, Client, Points) -> do_query(InstId, Client, Points) ->