Merge pull request #9360 from JimMoen/fix-api-method-case-sensitive

fix(api): uppercase api request method
This commit is contained in:
JimMoen 2022-11-14 23:38:05 +08:00 committed by GitHub
commit 1f05498b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -124,7 +124,10 @@ handle_request(_Method, _Path, Req) ->
cowboy_req:reply(400, #{<<"content-type">> => <<"text/plain">>}, <<"Not found.">>, Req).
authorize_appid(Req) ->
authorize_appid(cowboy_req:method(Req), cowboy_req:path(Req), Req).
authorize_appid(
iolist_to_binary(string:uppercase(cowboy_req:method(Req))),
iolist_to_binary(cowboy_req:path(Req)),
Req).
authorize_appid(<<"GET">>, <<"/api/v4/emqx_prometheus">>, _Req) ->
true;

View File

@ -107,7 +107,10 @@ http_handlers() ->
%%--------------------------------------------------------------------
is_authorized(Req) ->
is_authorized(cowboy_req:method(Req), cowboy_req:path(Req), Req).
is_authorized(
iolist_to_binary(string:uppercase(cowboy_req:method(Req))),
iolist_to_binary(cowboy_req:path(Req)),
Req).
is_authorized(<<"GET">>, <<"/api/v4/emqx_prometheus">>, _Req) ->
true;