chore(format): format some code
This commit is contained in:
parent
e283a3d165
commit
6a83cf3f35
|
@ -133,9 +133,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
docker-compose -f .ci/compatibility_tests/docker-compose-mysql-tls.yaml up -d
|
docker-compose -f .ci/compatibility_tests/docker-compose-mysql-tls.yaml up -d
|
||||||
sed -i 's|^[#[:space:]]*auth.mysql.ssl[[:space:]]*=.*|auth.mysql.ssl = on|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
sed -i 's|^[#[:space:]]*auth.mysql.ssl[[:space:]]*=.*|auth.mysql.ssl = on|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
||||||
sed -i 's|^[#[:space:]]*auth.mysql.cacertfile[[:space:]]*=.*|auth.mysql.cacertfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
# sed -i 's|^[#[:space:]]*auth.mysql.ssl.cacertfile[[:space:]]*=.*|auth.mysql.ssl.cacertfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
||||||
sed -i 's|^[#[:space:]]*auth.mysql.certfile[[:space:]]*=.*|auth.mysql.certfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-cert.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
# sed -i 's|^[#[:space:]]*auth.mysql.ssl.certfile[[:space:]]*=.*|auth.mysql.ssl.certfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-cert.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
||||||
sed -i 's|^[#[:space:]]*auth.mysql.keyfile[[:space:]]*=.*|auth.mysql.keyfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-key.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
# sed -i 's|^[#[:space:]]*auth.mysql.ssl.keyfile[[:space:]]*=.*|auth.mysql.ssl.keyfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-key.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
|
||||||
- name: setup
|
- name: setup
|
||||||
env:
|
env:
|
||||||
MYSQL_TAG: ${{ matrix.mysql_tag }}
|
MYSQL_TAG: ${{ matrix.mysql_tag }}
|
||||||
|
|
|
@ -197,10 +197,10 @@ validate([K|Keys], [V|Values]) ->
|
||||||
do_validation(login, all) ->
|
do_validation(login, all) ->
|
||||||
true;
|
true;
|
||||||
do_validation(login, {clientid, V}) when is_binary(V)
|
do_validation(login, {clientid, V}) when is_binary(V)
|
||||||
andalso byte_size(V) > 0->
|
andalso byte_size(V) > 0 ->
|
||||||
true;
|
true;
|
||||||
do_validation(login, {username, V}) when is_binary(V)
|
do_validation(login, {username, V}) when is_binary(V)
|
||||||
andalso byte_size(V) > 0->
|
andalso byte_size(V) > 0 ->
|
||||||
true;
|
true;
|
||||||
do_validation(topic, V) when is_binary(V)
|
do_validation(topic, V) when is_binary(V)
|
||||||
andalso byte_size(V) > 0 ->
|
andalso byte_size(V) > 0 ->
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
%% @doc Add Acls
|
%% @doc Add Acls
|
||||||
-spec(add_acl(login() |all, emqx_topic:topic(), pub | sub| pubsub, allow | deny) ->
|
-spec(add_acl(login() | all, emqx_topic:topic(), pub | sub | pubsub, allow | deny) ->
|
||||||
ok | {error, any()}).
|
ok | {error, any()}).
|
||||||
add_acl(Login, Topic, Action, Access) ->
|
add_acl(Login, Topic, Action, Access) ->
|
||||||
Acls = #?TABLE{
|
Acls = #?TABLE{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
init(#{clientid_list := ClientidList, username_list := UsernameList}) ->
|
init(#{clientid_list := ClientidList, username_list := UsernameList}) ->
|
||||||
ok = ekka_mnesia:create_table(emqx_user, [
|
ok = ekka_mnesia:create_table(?TABLE, [
|
||||||
{disc_copies, [node()]},
|
{disc_copies, [node()]},
|
||||||
{attributes, record_info(fields, emqx_user)},
|
{attributes, record_info(fields, emqx_user)},
|
||||||
{storage_properties, [{ets, [{read_concurrency, true}]}]}]),
|
{storage_properties, [{ets, [{read_concurrency, true}]}]}]),
|
||||||
|
@ -41,7 +41,7 @@ init(#{clientid_list := ClientidList, username_list := UsernameList}) ->
|
||||||
|| {Clientid, Password} <- ClientidList],
|
|| {Clientid, Password} <- ClientidList],
|
||||||
_ = [ add_default_user({{username, iolist_to_binary(Username)}, iolist_to_binary(Password)})
|
_ = [ add_default_user({{username, iolist_to_binary(Username)}, iolist_to_binary(Password)})
|
||||||
|| {Username, Password} <- UsernameList],
|
|| {Username, Password} <- UsernameList],
|
||||||
ok = ekka_mnesia:copy_table(emqx_user, disc_copies).
|
ok = ekka_mnesia:copy_table(?TABLE, disc_copies).
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
add_default_user({Login, Password}) when is_tuple(Login) ->
|
add_default_user({Login, Password}) when is_tuple(Login) ->
|
||||||
|
@ -55,8 +55,8 @@ check(ClientInfo = #{ clientid := Clientid
|
||||||
, password := NPassword
|
, password := NPassword
|
||||||
}, AuthResult, #{hash_type := HashType}) ->
|
}, AuthResult, #{hash_type := HashType}) ->
|
||||||
Username = maps:get(username, ClientInfo, undefined),
|
Username = maps:get(username, ClientInfo, undefined),
|
||||||
MatchSpec = ets:fun2ms(fun({?TABLE, {clientid, X }, Password, InterTime}) when X =:= Clientid-> Password;
|
MatchSpec = ets:fun2ms(fun({?TABLE, {clientid, X}, Password, InterTime}) when X =:= Clientid-> Password;
|
||||||
({?TABLE, {username, X }, Password, InterTime}) when X =:= Username andalso X =/= undefined -> Password
|
({?TABLE, {username, X}, Password, InterTime}) when X =:= Username andalso X =/= undefined -> Password
|
||||||
end),
|
end),
|
||||||
case ets:select(?TABLE, MatchSpec) of
|
case ets:select(?TABLE, MatchSpec) of
|
||||||
[] ->
|
[] ->
|
||||||
|
|
|
@ -128,7 +128,7 @@ add_clientid(_Bindings, Params) ->
|
||||||
Re = do_add_clientid(Params),
|
Re = do_add_clientid(Params),
|
||||||
case Re of
|
case Re of
|
||||||
ok -> return(ok);
|
ok -> return(ok);
|
||||||
{error, Error} -> {error, format_msg(Error)}
|
{error, Error} -> return({error, format_msg(Error)})
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ add_username(_Bindings, Params) ->
|
||||||
false ->
|
false ->
|
||||||
case do_add_username(Params) of
|
case do_add_username(Params) of
|
||||||
ok -> return(ok);
|
ok -> return(ok);
|
||||||
{error, Error} -> {error, format_msg(Error)}
|
{error, Error} -> return({error, format_msg(Error)})
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,10 @@
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
{mapping, "auth.mongo.login", "emqx_auth_mongo.server", [
|
{mapping, "auth.mongo.login", "emqx_auth_mongo.server", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "auth.mongo.username", "emqx_auth_mongo.server", [
|
{mapping, "auth.mongo.username", "emqx_auth_mongo.server", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -100,7 +98,7 @@
|
||||||
Pool = cuttlefish:conf_get("auth.mongo.pool", Conf),
|
Pool = cuttlefish:conf_get("auth.mongo.pool", Conf),
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
Login = cuttlefish:conf_get("auth.mongo.username", Conf,
|
Login = cuttlefish:conf_get("auth.mongo.username", Conf,
|
||||||
cuttlefish:conf_get("auth.mongo.login", Conf)
|
cuttlefish:conf_get("auth.mongo.login", Conf, "")
|
||||||
),
|
),
|
||||||
Passwd = cuttlefish:conf_get("auth.mongo.password", Conf),
|
Passwd = cuttlefish:conf_get("auth.mongo.password", Conf),
|
||||||
DB = cuttlefish:conf_get("auth.mongo.database", Conf),
|
DB = cuttlefish:conf_get("auth.mongo.database", Conf),
|
||||||
|
@ -131,17 +129,11 @@
|
||||||
{cacertfile, cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf, undefined)}])
|
{cacertfile, cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf, undefined)}])
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
|
||||||
GenSsl = case cuttlefish:conf_get("auth.mongo.ssl.cacertfile", Conf, undefined) of
|
|
||||||
undefined -> [{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl_opts")}];
|
|
||||||
_ -> [{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl")}]
|
|
||||||
end,
|
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
Ssl = case cuttlefish:conf_get("auth.mongo.ssl", Conf) of
|
Ssl = case cuttlefish:conf_get("auth.mongo.ssl", Conf) of
|
||||||
on -> GenSsl;
|
on -> [{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl")}];
|
||||||
off -> [];
|
off -> [];
|
||||||
true -> GenSsl;
|
true -> [{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl_opts")}];
|
||||||
false -> []
|
false -> []
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ auth.mysql.pool = 8
|
||||||
## MySQL username.
|
## MySQL username.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
# auth.mysql.username =
|
#auth.mysql.username =
|
||||||
|
|
||||||
## MySQL password.
|
## MySQL password.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
# auth.mysql.password =
|
#auth.mysql.password =
|
||||||
|
|
||||||
## MySQL database.
|
## MySQL database.
|
||||||
##
|
##
|
||||||
|
@ -98,19 +98,19 @@ auth.mysql.acl_query = select allow, ipaddr, username, clientid, access, topic f
|
||||||
## Mysql ssl configuration.
|
## Mysql ssl configuration.
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
## auth.mysql.ssl = off
|
#auth.mysql.ssl = off
|
||||||
|
|
||||||
## CA certificate.
|
## CA certificate.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
# auth.mysql.ssl.cacertfile = /path/to/ca.pem
|
#auth.mysql.ssl.cacertfile = /path/to/ca.pem
|
||||||
|
|
||||||
## Client ssl certificate.
|
## Client ssl certificate.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
## auth.mysql.ssl.certfile = path to your clientcert file
|
#auth.mysql.ssl.certfile = /path/to/your/clientcert.pem
|
||||||
|
|
||||||
## Client ssl keyfile.
|
## Client ssl keyfile.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
## auth.mysql.ssl.keyfile = path to your clientkey file
|
#auth.mysql.ssl.keyfile = /path/to/your/clientkey.pem
|
||||||
|
|
|
@ -36,23 +36,19 @@
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "auth.mysql.ssl.cafile", "emqx_auth_mysql.server", [
|
{mapping, "auth.mysql.ssl.cafile", "emqx_auth_mysql.server", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "auth.mysql.ssl.cacertfile", "emqx_auth_mysql.server", [
|
{mapping, "auth.mysql.ssl.cacertfile", "emqx_auth_mysql.server", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
{mapping, "auth.mysql.ssl.certfile", "emqx_auth_mysql.server", [
|
{mapping, "auth.mysql.ssl.certfile", "emqx_auth_mysql.server", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "auth.mysql.ssl.keyfile", "emqx_auth_mysql.server", [
|
{mapping, "auth.mysql.ssl.keyfile", "emqx_auth_mysql.server", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -78,28 +74,31 @@
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
Options = [{pool_size, Pool},
|
Options = [{pool_size, Pool},
|
||||||
{auto_reconnect, 1},
|
{auto_reconnect, 1},
|
||||||
{host, MyHost},
|
{host, MyHost},
|
||||||
{port, MyPort},
|
{port, MyPort},
|
||||||
{user, Username},
|
{user, Username},
|
||||||
{password, Passwd},
|
{password, Passwd},
|
||||||
{database, DB},
|
{database, DB},
|
||||||
{encoding, utf8},
|
{encoding, utf8},
|
||||||
{query_timeout, Timeout},
|
{query_timeout, Timeout},
|
||||||
{keep_alive, true}],
|
{keep_alive, true}],
|
||||||
|
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
||||||
Options1 =
|
Options1 =
|
||||||
case cuttlefish:conf_get("auth.mysql.ssl", Conf) of
|
case cuttlefish:conf_get("auth.mysql.ssl", Conf) of
|
||||||
true ->
|
true ->
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
CA = cuttlefish:conf_get("auth.mysql.ssl.cacertfile", Conf,
|
CA = cuttlefish:conf_get(
|
||||||
cuttlefish:conf_get("auth.mysql.ssl.cafile", Conf)
|
"auth.mysql.ssl.cacertfile", Conf,
|
||||||
),
|
cuttlefish:conf_get("auth.mysql.ssl.cafile", Conf, undefined)
|
||||||
Cert = cuttlefish:conf_get("auth.mysql.ssl.certfile", Conf),
|
),
|
||||||
Key = cuttlefish:conf_get("auth.mysql.ssl.keyfile", Conf),
|
Cert = cuttlefish:conf_get("auth.mysql.ssl.certfile", Conf, undefined),
|
||||||
Options ++ [{ssl, {server_name_indication, disable},
|
Key = cuttlefish:conf_get("auth.mysql.ssl.keyfile", Conf, undefined),
|
||||||
{cacertfile, CA},
|
Options ++ [{ssl, Filter([{server_name_indication, disable},
|
||||||
{certfile, Cert},
|
{cacertfile, CA},
|
||||||
{keyfile, Key}}];
|
{certfile, Cert},
|
||||||
|
{keyfile, Key}])
|
||||||
|
}];
|
||||||
_ ->
|
_ ->
|
||||||
Options
|
Options
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -45,30 +45,22 @@ auth.pgsql.ssl = off
|
||||||
## Example:
|
## Example:
|
||||||
## tlsv1.1,tlsv1.2,tlsv1.3
|
## tlsv1.1,tlsv1.2,tlsv1.3
|
||||||
##
|
##
|
||||||
## auth.pgsql.ssl_opts.tls_versions = tlsv1.2
|
#auth.pgsql.ssl.tls_versions = tlsv1.2
|
||||||
|
|
||||||
## TLS version
|
|
||||||
## You can configure multi-version use "," split,
|
|
||||||
## default value is :tlsv1.2
|
|
||||||
## Example:
|
|
||||||
## tlsv1.1,tlsv1.2,tlsv1.3
|
|
||||||
##
|
|
||||||
## auth.pgsql.ssl.tls_versions = tlsv1.2
|
|
||||||
|
|
||||||
## SSL keyfile.
|
## SSL keyfile.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
## auth.pgsql.ssl.keyfile =
|
#auth.pgsql.ssl.keyfile =
|
||||||
|
|
||||||
## SSL certfile.
|
## SSL certfile.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
## auth.pgsql.ssl.certfile =
|
#auth.pgsql.ssl.certfile =
|
||||||
|
|
||||||
## SSL cacertfile.
|
## SSL cacertfile.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
## auth.pgsql.ssl.cacertfile =
|
#auth.pgsql.ssl.cacertfile =
|
||||||
|
|
||||||
## Authentication query.
|
## Authentication query.
|
||||||
##
|
##
|
||||||
|
|
|
@ -97,17 +97,11 @@
|
||||||
||Value <- string:tokens(cuttlefish:conf_get(Prefix ++ ".tls_versions", Conf), " ,")]}}])
|
||Value <- string:tokens(cuttlefish:conf_get(Prefix ++ ".tls_versions", Conf), " ,")]}}])
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
|
||||||
GenSsl = case cuttlefish:conf_get("auth.pgsql.ssl.cacertfile", Conf, undefined) of
|
|
||||||
undefined -> [{ssl, true}, {ssl_opts, SslOpts("auth.pgsql.ssl_opts")}];
|
|
||||||
_ -> [{ssl, true}, {ssl_opts, SslOpts("auth.pgsql.ssl")}]
|
|
||||||
end,
|
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
Ssl = case cuttlefish:conf_get("auth.pgsql.ssl", Conf) of
|
Ssl = case cuttlefish:conf_get("auth.pgsql.ssl", Conf) of
|
||||||
on -> GenSsl;
|
on -> [{ssl, true}, {ssl_opts, SslOpts("auth.pgsql.ssl")}];
|
||||||
off -> [];
|
off -> [];
|
||||||
true -> GenSsl;
|
true -> [{ssl, true}, {ssl_opts, SslOpts("auth.pgsql.ssl_opts")}];
|
||||||
false -> []
|
false -> []
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,10 @@
|
||||||
, equery/3
|
, equery/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-type client_info() :: #{username:=_, clientid:=_, peerhost:=_, _=>_}.
|
-type client_info() :: #{username := _,
|
||||||
|
clientid := _,
|
||||||
|
peerhost := _,
|
||||||
|
_ => _}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Avoid SQL Injection: Parse SQL to Parameter Query.
|
%% Avoid SQL Injection: Parse SQL to Parameter Query.
|
||||||
|
|
|
@ -103,7 +103,7 @@ auth.redis.acl_cmd = HGETALL mqtt_acl:%u
|
||||||
## CA certificate.
|
## CA certificate.
|
||||||
##
|
##
|
||||||
## Value: File
|
## Value: File
|
||||||
# auth.redis.ssl.cacertfile = path/to/your/cafile.pem
|
#auth.redis.ssl.cacertfile = path/to/your/cafile.pem
|
||||||
|
|
||||||
## Client ssl certificate.
|
## Client ssl certificate.
|
||||||
##
|
##
|
||||||
|
|
|
@ -39,18 +39,14 @@
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "auth.redis.ssl.cacertfile", "emqx_auth_redis.options", [
|
{mapping, "auth.redis.ssl.cacertfile", "emqx_auth_redis.options", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
|
||||||
{mapping, "auth.redis.ssl.certfile", "emqx_auth_redis.options", [
|
{mapping, "auth.redis.ssl.certfile", "emqx_auth_redis.options", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "auth.redis.ssl.keyfile", "emqx_auth_redis.options", [
|
{mapping, "auth.redis.ssl.keyfile", "emqx_auth_redis.options", [
|
||||||
{default, ""},
|
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -74,19 +70,27 @@
|
||||||
|
|
||||||
{translation, "emqx_auth_redis.options", fun(Conf) ->
|
{translation, "emqx_auth_redis.options", fun(Conf) ->
|
||||||
Ssl = cuttlefish:conf_get("auth.redis.ssl", Conf, false),
|
Ssl = cuttlefish:conf_get("auth.redis.ssl", Conf, false),
|
||||||
|
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
||||||
case Ssl of
|
case Ssl of
|
||||||
true ->
|
true ->
|
||||||
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
|
||||||
Prefix = case cuttlefish:conf_get("auth.redis.ssl.cacertfile", Conf, undefined) of
|
CA = cuttlefish:conf_get(
|
||||||
undefined -> "auth.redis";
|
"auth.redis.ssl.cacertfile", Conf,
|
||||||
_ -> "auth.redis.ssl"
|
cuttlefish:conf_get("auth.redis.cacertfile", Conf, undefined)
|
||||||
end,
|
),
|
||||||
CA = cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf),
|
Cert = cuttlefish:conf_get(
|
||||||
Cert = cuttlefish:conf_get(Prefix ++ ".certfile", Conf),
|
"auth.redis.ssl.certfile", Conf,
|
||||||
Key = cuttlefish:conf_get(Prefix ++ ".keyfile", Conf),
|
cuttlefish:conf_get("auth.redis.certfile", Conf, undefined)
|
||||||
[{options, [{ssl_options, [{cacertfile, CA},
|
),
|
||||||
{certfile, Cert},
|
Key = cuttlefish:conf_get(
|
||||||
{keyfile, Key}]}]}];
|
"auth.redis.ssl.keyfile", Conf,
|
||||||
|
cuttlefish:conf_get("auth.redis.keyfile", Conf, undefined)
|
||||||
|
),
|
||||||
|
[{options, [{ssl_options,
|
||||||
|
Filter([{cacertfile, CA},
|
||||||
|
{certfile, Cert},
|
||||||
|
{keyfile, Key}])
|
||||||
|
}]}];
|
||||||
_ -> [{options, []}]
|
_ -> [{options, []}]
|
||||||
end
|
end
|
||||||
end}.
|
end}.
|
||||||
|
|
|
@ -192,8 +192,8 @@ do_register_hooks(Hook, ScriptName, _St) ->
|
||||||
?LOG(error, "Discard unknown hook type ~p from ~p", [Hook, ScriptName]).
|
?LOG(error, "Discard unknown hook type ~p from ~p", [Hook, ScriptName]).
|
||||||
|
|
||||||
do_unloadall(Scripts) ->
|
do_unloadall(Scripts) ->
|
||||||
lists:foreach(fun do_unload/1, Scripts),
|
lists:foreach(fun do_unload/1, Scripts).
|
||||||
ok.
|
|
||||||
|
|
||||||
do_unload(Script) ->
|
do_unload(Script) ->
|
||||||
emqx_lua_script:unregister_hooks(Script), ok.
|
emqx_lua_script:unregister_hooks(Script),
|
||||||
|
ok.
|
||||||
|
|
|
@ -99,11 +99,11 @@ add_app(AppId, Name, Secret, Desc, Status, Expired) when is_binary(AppId) ->
|
||||||
AddFun = fun() ->
|
AddFun = fun() ->
|
||||||
case mnesia:wread({mqtt_app, AppId}) of
|
case mnesia:wread({mqtt_app, AppId}) of
|
||||||
[] -> mnesia:write(App);
|
[] -> mnesia:write(App);
|
||||||
_ -> mnesia:abort(alread_existed), ok
|
_ -> mnesia:abort(alread_existed)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case mnesia:transaction(AddFun) of
|
case mnesia:transaction(AddFun) of
|
||||||
{atomic, _} -> {ok, Secret1};
|
{atomic, ok} -> {ok, Secret1};
|
||||||
{aborted, Reason} -> {error, Reason}
|
{aborted, Reason} -> {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
-module(emqx_sn_proper_types).
|
-module(emqx_sn_proper_types).
|
||||||
|
|
||||||
%-include("emqx_sn.hrl").
|
|
||||||
-include_lib("emqx_sn/include/emqx_sn.hrl").
|
-include_lib("emqx_sn/include/emqx_sn.hrl").
|
||||||
-include_lib("proper/include/proper.hrl").
|
-include_lib("proper/include/proper.hrl").
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
-module(prop_emqx_sn_frame).
|
-module(prop_emqx_sn_frame).
|
||||||
|
|
||||||
%-include("emqx_sn.hrl").
|
|
||||||
-include_lib("emqx_sn/include/emqx_sn.hrl").
|
-include_lib("emqx_sn/include/emqx_sn.hrl").
|
||||||
-include_lib("proper/include/proper.hrl").
|
-include_lib("proper/include/proper.hrl").
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ set_special_configs_https(_) ->
|
||||||
Path = emqx_ct_helpers:deps_path(emqx_web_hook, "test/emqx_web_hook_SUITE_data/"),
|
Path = emqx_ct_helpers:deps_path(emqx_web_hook, "test/emqx_web_hook_SUITE_data/"),
|
||||||
SslOpts = [{keyfile, Path ++ "/client-key.pem"},
|
SslOpts = [{keyfile, Path ++ "/client-key.pem"},
|
||||||
{certfile, Path ++ "/client-cert.pem"},
|
{certfile, Path ++ "/client-cert.pem"},
|
||||||
{cafile, Path ++ "/ca.pem"}],
|
{cacertfile, Path ++ "/ca.pem"}],
|
||||||
application:set_env(emqx_web_hook, ssl, true),
|
application:set_env(emqx_web_hook, ssl, true),
|
||||||
application:set_env(emqx_web_hook, ssloptions, SslOpts),
|
application:set_env(emqx_web_hook, ssloptions, SslOpts),
|
||||||
application:set_env(emqx_web_hook, url, "https://127.0.0.1:8888").
|
application:set_env(emqx_web_hook, url, "https://127.0.0.1:8888").
|
||||||
|
|
Loading…
Reference in New Issue