Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth mnesia): parsing the http body parameter does not require url decode #5674

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/emqx_auth_mnesia/src/emqx_acl_mnesia_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ do_add(Params) ->
Username = get_value(<<"username">>, Params, undefined),
Login = case {Clientid, Username} of
{undefined, undefined} -> all;
{_, undefined} -> {clientid, urldecode(Clientid)};
{undefined, _} -> {username, urldecode(Username)}
{_, undefined} -> {clientid, Clientid};
{undefined, _} -> {username, Username}
end,
Topic = urldecode(get_value(<<"topic">>, Params)),
Action = urldecode(get_value(<<"action">>, Params)),
Access = urldecode(get_value(<<"access">>, Params)),
Topic = get_value(<<"topic">>, Params),
Action = get_value(<<"action">>, Params),
Access = get_value(<<"access">>, Params),
Re = case validate([login, topic, action, access], [Login, Topic, Action, Access]) of
ok ->
emqx_acl_mnesia_cli:add_acl(Login, Topic, erlang:binary_to_atom(Action, utf8), erlang:binary_to_atom(Access, utf8));
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_auth_mnesia/src/emqx_auth_mnesia.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, emqx_auth_mnesia,
[{description, "EMQ X Authentication with Mnesia"},
{vsn, "4.3.2"}, % strict semver, bump manually
{vsn, "4.3.3"}, % strict semver, bump manually
{modules, []},
{registered, []},
{applications, [kernel,stdlib,mnesia]},
Expand Down
8 changes: 8 additions & 0 deletions apps/emqx_auth_mnesia/src/emqx_auth_mnesia.appup.src
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

{VSN,
[
{"4.3.2", [
{load_module,emqx_acl_mnesia_api, brutal_purge,soft_purge,[]},
{load_module,emqx_auth_mnesia_api, brutal_purge,soft_purge,[]}
]},
{"4.3.1", [
{load_module,emqx_auth_mnesia_api, brutal_purge,soft_purge,[]}
]},
Expand All @@ -11,6 +15,10 @@
{<<".*">>, []}
],
[
{"4.3.2", [
{load_module,emqx_acl_mnesia_api, brutal_purge,soft_purge,[]},
{load_module,emqx_auth_mnesia_api, brutal_purge,soft_purge,[]}
]},
{"4.3.1", [
{load_module,emqx_auth_mnesia_api, brutal_purge,soft_purge,[]}
]},
Expand Down
8 changes: 4 additions & 4 deletions apps/emqx_auth_mnesia/src/emqx_auth_mnesia_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ add_clientid(_Bindings, Params) ->
end.

do_add_clientid([ Params | ParamsN ], ReList ) ->
Clientid = urldecode(get_value(<<"clientid">>, Params)),
Clientid = get_value(<<"clientid">>, Params),
do_add_clientid(ParamsN, [{Clientid, format_msg(do_add_clientid(Params))} | ReList]);

do_add_clientid([], ReList) ->
{ok, ReList}.

do_add_clientid(Params) ->
Clientid = urldecode(get_value(<<"clientid">>, Params)),
Clientid = get_value(<<"clientid">>, Params),
Password = get_value(<<"password">>, Params),
Login = {clientid, Clientid},
case validate([login, password], [Login, Password]) of
Expand Down Expand Up @@ -182,14 +182,14 @@ add_username(_Bindings, Params) ->
end.

do_add_username([ Params | ParamsN ], ReList ) ->
Username = urldecode(get_value(<<"username">>, Params)),
Username = get_value(<<"username">>, Params),
do_add_username(ParamsN, [{Username, format_msg(do_add_username(Params))} | ReList]);

do_add_username([], ReList) ->
{ok, ReList}.

do_add_username(Params) ->
Username = urldecode(get_value(<<"username">>, Params)),
Username = get_value(<<"username">>, Params),
Password = get_value(<<"password">>, Params),
Login = {username, Username},
case validate([login, password], [Login, Password]) of
Expand Down