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) ->
|
||||
{noreply, State}.
|
||||
|
||||
format_status(State) ->
|
||||
censor_secrets(State).
|
||||
format_status(Status = #{state := State}) ->
|
||||
Status#{state => censor_secrets(State)}.
|
||||
|
||||
format_status(_Opt, [_PDict, State0]) ->
|
||||
State = censor_secrets(State0),
|
||||
|
@ -222,16 +222,13 @@ ensure_timer(State) ->
|
|||
State.
|
||||
|
||||
-spec censor_secrets(state()) -> map().
|
||||
censor_secrets(State) ->
|
||||
maps:map(
|
||||
fun
|
||||
(Key, _Value) when
|
||||
Key =:= jwt;
|
||||
Key =:= jwk
|
||||
->
|
||||
"******";
|
||||
(_Key, Value) ->
|
||||
Value
|
||||
end,
|
||||
State
|
||||
).
|
||||
censor_secrets(State = #{jwt := JWT, jwk := JWK}) ->
|
||||
State#{
|
||||
jwt := censor_secret(JWT),
|
||||
jwk := censor_secret(JWK)
|
||||
}.
|
||||
|
||||
censor_secret(undefined) ->
|
||||
undefined;
|
||||
censor_secret(_Secret) ->
|
||||
"******".
|
||||
|
|
Loading…
Reference in New Issue