feat(rocketmq): accept wrapped secrets as passwords

This commit is contained in:
Andrew Mayorov 2023-11-13 13:05:31 +07:00
parent 2449d54b1f
commit 7817502b8b
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 14 additions and 21 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_rocketmq, [ {application, emqx_bridge_rocketmq, [
{description, "EMQX Enterprise RocketMQ Bridge"}, {description, "EMQX Enterprise RocketMQ Bridge"},
{vsn, "0.1.3"}, {vsn, "0.1.4"},
{registered, []}, {registered, []},
{applications, [kernel, stdlib, emqx_resource, rocketmq]}, {applications, [kernel, stdlib, emqx_resource, rocketmq]},
{env, []}, {env, []},

View File

@ -48,13 +48,8 @@ fields(config) ->
binary(), binary(),
#{default => <<>>, desc => ?DESC("access_key")} #{default => <<>>, desc => ?DESC("access_key")}
)}, )},
{secret_key, {secret_key, emqx_schema_secret:mk(#{default => <<>>, desc => ?DESC("secret_key")})},
mk( {security_token, emqx_schema_secret:mk(#{default => <<>>, desc => ?DESC(security_token)})},
binary(),
#{default => <<>>, desc => ?DESC("secret_key"), sensitive => true}
)},
{security_token,
mk(binary(), #{default => <<>>, desc => ?DESC(security_token), sensitive => true})},
{sync_timeout, {sync_timeout,
mk( mk(
emqx_schema:timeout_duration(), emqx_schema:timeout_duration(),
@ -294,21 +289,19 @@ make_producer_opts(
acl_info => emqx_secret:wrap(ACLInfo) acl_info => emqx_secret:wrap(ACLInfo)
}. }.
acl_info(<<>>, <<>>, <<>>) -> acl_info(<<>>, _, _) ->
#{}; #{};
acl_info(AccessKey, SecretKey, <<>>) when is_binary(AccessKey), is_binary(SecretKey) -> acl_info(AccessKey, SecretKey, SecurityToken) when is_binary(AccessKey) ->
#{ Info = #{
access_key => AccessKey, access_key => AccessKey,
secret_key => SecretKey secret_key => emqx_maybe:define(emqx_secret:unwrap(SecretKey), <<>>)
}; },
acl_info(AccessKey, SecretKey, SecurityToken) when case emqx_maybe:define(emqx_secret:unwrap(SecurityToken), <<>>) of
is_binary(AccessKey), is_binary(SecretKey), is_binary(SecurityToken) <<>> ->
-> Info;
#{ Token ->
access_key => AccessKey, Info#{security_token => Token}
secret_key => SecretKey, end;
security_token => SecurityToken
};
acl_info(_, _, _) -> acl_info(_, _, _) ->
#{}. #{}.