Merge pull request #5214 from tigercl/improve/authn

chore(auhtn): keep one ssl opts checking func
This commit is contained in:
tigercl 2021-07-12 16:52:37 +08:00 committed by GitHub
commit 76f185538e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 12 deletions

View File

@ -72,7 +72,7 @@ common_fields() ->
] ++ proplists:delete(base_url, emqx_connector_http:fields(config)).
validations() ->
[ {check_ssl_opts, fun check_ssl_opts/1} ].
[ {check_ssl_opts, fun emqx_connector_http:check_ssl_opts/1} ].
url(type) -> binary();
url(nullable) -> false;
@ -190,17 +190,6 @@ check_form_data(FormData) ->
false
end.
check_ssl_opts(Conf) ->
URL = hocon_schema:get_value("url", Conf),
{ok, #{scheme := Scheme}} = emqx_http_lib:uri_parse(URL),
SSLOpts = hocon_schema:get_value("ssl_opts", Conf),
case {Scheme, SSLOpts} of
{http, undefined} -> true;
{http, _} -> false;
{https, undefined} -> false;
{https, _} -> true
end.
preprocess_form_data(FormData) ->
KVs = binary:split(FormData, [<<"&">>], [global]),
[list_to_tuple(binary:split(KV, [<<"=">>], [global])) || KV <- KVs].

View File

@ -32,6 +32,8 @@
, fields/1
, validations/0]).
-export([ check_ssl_opts/1 ]).
-type connect_timeout() :: non_neg_integer() | infinity.
-type pool_type() :: random | hash.