Add ClientId parameter into the auth on HTTP Publish

This commit is contained in:
Chimit 2017-02-07 18:24:37 +08:00
parent ed05521725
commit aefe0ab4ac
1 changed files with 3 additions and 1 deletions

View File

@ -128,13 +128,15 @@ validate(topic, Topic) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
authorized(Req) -> authorized(Req) ->
Params = mochiweb_request:parse_post(Req),
ClientId = get_value("client", Params, http),
case Req:get_header_value("Authorization") of case Req:get_header_value("Authorization") of
undefined -> undefined ->
false; false;
"Basic " ++ BasicAuth -> "Basic " ++ BasicAuth ->
{Username, Password} = user_passwd(BasicAuth), {Username, Password} = user_passwd(BasicAuth),
{ok, Peer} = Req:get(peername), {ok, Peer} = Req:get(peername),
case emqttd_access_control:auth(#mqtt_client{username = Username, peername = Peer}, Password) of case emqttd_access_control:auth(#mqtt_client{client_id = ClientId, username = Username, peername = Peer}, Password) of
ok -> ok ->
true; true;
{ok, _IsSuper} -> {ok, _IsSuper} ->