Merge pull request #9437 from zhongwencool/authn-env-failed

fix: set authentication array from ENV failed
This commit is contained in:
Zaiming (Stone) Shi 2022-12-12 19:12:27 +01:00 committed by GitHub
commit f8685e3a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -71,8 +71,15 @@ do_check_config(#{<<"mechanism">> := Mec} = Config, Opts) ->
Opts#{atom_key => true} Opts#{atom_key => true}
) )
end; end;
do_check_config(_Config, _Opts) -> do_check_config(Config, _Opts) when is_map(Config) ->
throw({invalid_config, "mechanism_field_required"}). throw({invalid_config, "mechanism_field_required", Config});
do_check_config(RawConf, Opts) ->
%% authentication conf is lazy type, when it comes from ENV, it is a string
%% EMQX_AUTHENTICATION__1="{mechanism=\"password_based\"...}"
case hocon:binary(RawConf, Opts) of
{ok, Conf} -> do_check_config(Conf, Opts);
{error, Reason} -> throw({invalid_config, Reason})
end.
atom(Bin) -> atom(Bin) ->
try try