feat(greptimedb): accept wrapped secrets as passwords

This commit is contained in:
Andrew Mayorov 2023-11-13 14:50:58 +07:00
parent 5d620465e2
commit d4dd4508c9
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 4 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_greptimedb, [ {application, emqx_bridge_greptimedb, [
{description, "EMQX GreptimeDB Bridge"}, {description, "EMQX GreptimeDB Bridge"},
{vsn, "0.1.3"}, {vsn, "0.1.4"},
{registered, []}, {registered, []},
{applications, [ {applications, [
kernel, kernel,

View File

@ -147,13 +147,7 @@ fields(greptimedb) ->
[ [
{dbname, mk(binary(), #{required => true, desc => ?DESC("dbname")})}, {dbname, mk(binary(), #{required => true, desc => ?DESC("dbname")})},
{username, mk(binary(), #{desc => ?DESC("username")})}, {username, mk(binary(), #{desc => ?DESC("username")})},
{password, {password, emqx_schema_secret:mk(#{desc => ?DESC("password")})}
mk(binary(), #{
desc => ?DESC("password"),
format => <<"password">>,
sensitive => true,
converter => fun emqx_schema:password_converter/2
})}
] ++ emqx_connector_schema_lib:ssl_fields(). ] ++ emqx_connector_schema_lib:ssl_fields().
server() -> server() ->
@ -302,7 +296,8 @@ ssl_config(SSL = #{enable := true}) ->
auth(#{username := Username, password := Password}) -> auth(#{username := Username, password := Password}) ->
[ [
{auth, {basic, #{username => str(Username), password => str(Password)}}} %% TODO: teach `greptimedb` to accept 0-arity closures as passwords.
{auth, {basic, #{username => str(Username), password => emqx_secret:unwrap(Password)}}}
]; ];
auth(_) -> auth(_) ->
[]. [].