From 7b5340ce094d08981b8170f20a1474d7634d75f2 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Mon, 14 Nov 2022 17:55:17 +0800 Subject: [PATCH] fix(api): uppercase api request method --- apps/emqx_management/src/emqx_mgmt_http.erl | 5 ++++- lib-ce/emqx_dashboard/src/emqx_dashboard.erl | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_http.erl b/apps/emqx_management/src/emqx_mgmt_http.erl index 57c54ed3f..99263fbfd 100644 --- a/apps/emqx_management/src/emqx_mgmt_http.erl +++ b/apps/emqx_management/src/emqx_mgmt_http.erl @@ -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; diff --git a/lib-ce/emqx_dashboard/src/emqx_dashboard.erl b/lib-ce/emqx_dashboard/src/emqx_dashboard.erl index 3ad0694c4..fa3f0e7df 100644 --- a/lib-ce/emqx_dashboard/src/emqx_dashboard.erl +++ b/lib-ce/emqx_dashboard/src/emqx_dashboard.erl @@ -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;