chore: no type check for 3rd party auth
This commit is contained in:
parent
fbc52330f3
commit
65319567cc
|
@ -759,9 +759,10 @@ maybe_unhook(State) ->
|
|||
State.
|
||||
|
||||
do_create_authenticator(AuthenticatorID, #{enable := Enable} = Config, Providers) ->
|
||||
case maps:get(authn_type(Config), Providers, undefined) of
|
||||
Type = authn_type(Config),
|
||||
case maps:get(Type, Providers, undefined) of
|
||||
undefined ->
|
||||
{error, no_available_provider};
|
||||
{error, {no_available_provider_for, Type}};
|
||||
Provider ->
|
||||
case Provider:create(AuthenticatorID, Config) of
|
||||
{ok, State} ->
|
||||
|
|
|
@ -52,50 +52,10 @@
|
|||
)
|
||||
).
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% Hocon Schema
|
||||
%%------------------------------------------------------------------------------
|
||||
|
||||
roots() ->
|
||||
[
|
||||
{config, #{
|
||||
type => hoconsc:union([
|
||||
hoconsc:ref(?MODULE, type1),
|
||||
hoconsc:ref(?MODULE, type2)
|
||||
])
|
||||
}}
|
||||
].
|
||||
|
||||
fields(type1) ->
|
||||
[
|
||||
{mechanism, {enum, [password_based]}},
|
||||
{backend, {enum, [built_in_database]}},
|
||||
{enable, fun enable/1}
|
||||
];
|
||||
fields(type2) ->
|
||||
[
|
||||
{mechanism, {enum, [password_based]}},
|
||||
{backend, {enum, [mysql]}},
|
||||
{enable, fun enable/1}
|
||||
].
|
||||
|
||||
enable(type) -> boolean();
|
||||
enable(default) -> true;
|
||||
enable(_) -> undefined.
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% Callbacks
|
||||
%%------------------------------------------------------------------------------
|
||||
|
||||
check_config(C) ->
|
||||
#{config := R} =
|
||||
hocon_tconf:check_plain(
|
||||
?MODULE,
|
||||
#{<<"config">> => C},
|
||||
#{atom_key => true}
|
||||
),
|
||||
R.
|
||||
|
||||
create(_AuthenticatorID, _Config) ->
|
||||
{ok, #{mark => 1}}.
|
||||
|
||||
|
@ -200,7 +160,7 @@ t_authenticator(Config) when is_list(Config) ->
|
|||
% Create an authenticator when the provider does not exist
|
||||
|
||||
?assertEqual(
|
||||
{error, no_available_provider},
|
||||
{error, {no_available_provider_for, {password_based, built_in_database}}},
|
||||
?AUTHN:create_authenticator(ChainName, AuthenticatorConfig1)
|
||||
),
|
||||
|
||||
|
@ -335,14 +295,14 @@ t_update_config(Config) when is_list(Config) ->
|
|||
ok = register_provider(?config("auth2"), ?MODULE),
|
||||
Global = ?config(global),
|
||||
AuthenticatorConfig1 = #{
|
||||
<<"mechanism">> => <<"password_based">>,
|
||||
<<"backend">> => <<"built_in_database">>,
|
||||
<<"enable">> => true
|
||||
mechanism => password_based,
|
||||
backend => built_in_database,
|
||||
enable => true
|
||||
},
|
||||
AuthenticatorConfig2 = #{
|
||||
<<"mechanism">> => <<"password_based">>,
|
||||
<<"backend">> => <<"mysql">>,
|
||||
<<"enable">> => true
|
||||
mechanism => password_based,
|
||||
backend => mysql,
|
||||
enable => true
|
||||
},
|
||||
ID1 = <<"password_based:built_in_database">>,
|
||||
ID2 = <<"password_based:mysql">>,
|
||||
|
|
Loading…
Reference in New Issue