Просмотр исходного кода

chore(auhtn): keep one ssl opts checking func

zhouzb 4 лет назад
Родитель
Сommit
5bb55332a5

+ 1 - 12
apps/emqx_authn/src/simple_authn/emqx_authn_http.erl

@@ -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].

+ 2 - 0
apps/emqx_connector/src/emqx_connector_http.erl

@@ -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.