fix(oidc): Avoid crashes and avoid deleting jwks on update

This commit is contained in:
firest 2024-07-10 15:22:43 +08:00
parent 50e6ee4c88
commit b0e3e405cf
2 changed files with 12 additions and 3 deletions

View File

@ -181,12 +181,16 @@ create(#{name_var := NameVar} = Config) ->
end.
update(Config, State) ->
destroy(State),
destroy(State, false),
create(Config).
destroy(State) ->
destroy(State, true).
destroy(State, TryDelete) ->
emqx_dashboard_sso_oidc_session:stop(),
try_delete_jwks_file(State).
_ = TryDelete andalso try_delete_jwks_file(State),
ok.
-dialyzer({nowarn_function, login/2}).
login(

View File

@ -35,6 +35,8 @@
-define(DEFAULT_RANDOM_LEN, 32).
-define(NOW, erlang:system_time(millisecond)).
-define(BACKOFF_MIN, 5000).
-define(BACKOFF_MAX, 10000).
%%------------------------------------------------------------------------------
%% API
@ -49,7 +51,10 @@ start(Name, #{issuer := Issuer, session_expiry := SessionExpiry0}) ->
[
#{
issuer => Issuer,
name => {local, Name}
name => {local, Name},
backoff_min => ?BACKOFF_MIN,
backoff_max => ?BACKOFF_MAX,
backoff_type => random
}
]
)