fix: redact api request to hide auth token

This commit is contained in:
JimMoen 2023-05-29 10:58:30 +08:00
parent c2450d230d
commit dcfe985ee9
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
4 changed files with 8 additions and 3 deletions

View File

@ -21,11 +21,12 @@
-export([init/2]).
init(Req0, State) ->
?SLOG(warning, #{msg => "unexpected_api_access", request => Req0}),
RedactedReq = emqx_utils:redact(Req0),
?SLOG(warning, #{msg => "unexpected_api_access", request => RedactedReq}),
Req = cowboy_req:reply(
404,
#{<<"content-type">> => <<"application/json">>},
<<"{\"code\": \"API_NOT_EXIST\", \"message\": \"Request Path Not Found\"}">>,
Req0
RedactedReq
),
{ok, Req, State}.

View File

@ -2,7 +2,7 @@
{application, emqx_utils, [
{description, "Miscellaneous utilities for EMQX apps"},
% strict semver, bump manually!
{vsn, "5.0.1"},
{vsn, "5.0.2"},
{modules, [
emqx_utils,
emqx_utils_api,

View File

@ -575,6 +575,9 @@ try_to_existing_atom(Convert, Data, Encoding) ->
is_sensitive_key(token) -> true;
is_sensitive_key("token") -> true;
is_sensitive_key(<<"token">>) -> true;
is_sensitive_key(authorization) -> true;
is_sensitive_key("authorization") -> true;
is_sensitive_key(<<"authorization">>) -> true;
is_sensitive_key(password) -> true;
is_sensitive_key("password") -> true;
is_sensitive_key(<<"password">>) -> true;

View File

@ -0,0 +1 @@
Obfuscated sensitive data in the bad API logging.