fix: handle status in `format_status/1` callback
Which is expected argument type for this callback. Also try to make sure that random maps won't pass through this callback unnoticed.
This commit is contained in:
parent
aece9fb96f
commit
ed2d5aa48a
|
@ -154,8 +154,8 @@ handle_info({timeout, TRef, ?refresh_jwt}, State0 = #{refresh_timer := TRef}) ->
|
||||||
handle_info(_Msg, State) ->
|
handle_info(_Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
format_status(State) ->
|
format_status(Status = #{state := State}) ->
|
||||||
censor_secrets(State).
|
Status#{state => censor_secrets(State)}.
|
||||||
|
|
||||||
format_status(_Opt, [_PDict, State0]) ->
|
format_status(_Opt, [_PDict, State0]) ->
|
||||||
State = censor_secrets(State0),
|
State = censor_secrets(State0),
|
||||||
|
@ -222,16 +222,13 @@ ensure_timer(State) ->
|
||||||
State.
|
State.
|
||||||
|
|
||||||
-spec censor_secrets(state()) -> map().
|
-spec censor_secrets(state()) -> map().
|
||||||
censor_secrets(State) ->
|
censor_secrets(State = #{jwt := JWT, jwk := JWK}) ->
|
||||||
maps:map(
|
State#{
|
||||||
fun
|
jwt := censor_secret(JWT),
|
||||||
(Key, _Value) when
|
jwk := censor_secret(JWK)
|
||||||
Key =:= jwt;
|
}.
|
||||||
Key =:= jwk
|
|
||||||
->
|
censor_secret(undefined) ->
|
||||||
"******";
|
undefined;
|
||||||
(_Key, Value) ->
|
censor_secret(_Secret) ->
|
||||||
Value
|
"******".
|
||||||
end,
|
|
||||||
State
|
|
||||||
).
|
|
||||||
|
|
Loading…
Reference in New Issue