refactor(auth_redis): delete backward-compatible code in config schema

This commit is contained in:
Zaiming Shi 2021-01-22 09:53:00 +01:00
parent 5d45325cb8
commit 7bb590f1c7
1 changed files with 6 additions and 30 deletions

View File

@ -43,7 +43,6 @@
{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, ""}, {default, ""},
{datatype, string} {datatype, string}
@ -54,40 +53,17 @@
{datatype, string} {datatype, string}
]}. ]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.cafile", "emqx_auth_redis.options", [
{default, ""},
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.certfile", "emqx_auth_redis.options", [
{default, ""},
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.keyfile", "emqx_auth_redis.options", [
{default, ""},
{datatype, string}
]}.
{translation, "emqx_auth_redis.options", fun(Conf) -> {translation, "emqx_auth_redis.options", fun(Conf) ->
Ssl = cuttlefish:conf_get("auth.redis.ssl.enable", Conf, false), case cuttlefish:conf_get("auth.redis.ssl.enable", Conf, false) of
case Ssl of
true -> true ->
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0 CA = cuttlefish:conf_get("auth.redis.ssl.cacertfile", Conf),
Prefix = case cuttlefish:conf_get("auth.redis.ssl.cacertfile", Conf, undefined) of Cert = cuttlefish:conf_get("auth.redis.ssl.certfile", Conf),
undefined -> "auth.redis"; Key = cuttlefish:conf_get("auth.redis.ssl.keyfile", Conf),
_ -> "auth.redis.ssl"
end,
CA = cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf),
Cert = cuttlefish:conf_get(Prefix ++ ".certfile", Conf),
Key = cuttlefish:conf_get(Prefix ++ ".keyfile", Conf),
[{options, [{ssl_options, [{cacertfile, CA}, [{options, [{ssl_options, [{cacertfile, CA},
{certfile, Cert}, {certfile, Cert},
{keyfile, Key}]}]}]; {keyfile, Key}]}]}];
_ -> [{options, []}] false ->
[{options, []}]
end end
end}. end}.