fix(authn_redis): fix that redis authn will deny the unknown users
This commit is contained in:
parent
de06d1c539
commit
a770447e75
|
@ -149,8 +149,8 @@ authenticate(
|
||||||
of
|
of
|
||||||
ok ->
|
ok ->
|
||||||
{ok, emqx_authn_utils:is_superuser(Selected)};
|
{ok, emqx_authn_utils:is_superuser(Selected)};
|
||||||
{error, Reason} ->
|
{error, _Reason} ->
|
||||||
{error, Reason}
|
ignore
|
||||||
end;
|
end;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?TRACE_AUTHN_PROVIDER(error, "redis_query_failed", #{
|
?TRACE_AUTHN_PROVIDER(error, "redis_query_failed", #{
|
||||||
|
|
|
@ -173,6 +173,9 @@ test_user_auth(#{
|
||||||
{create_authenticator, ?GLOBAL, AuthConfig}
|
{create_authenticator, ?GLOBAL, AuthConfig}
|
||||||
),
|
),
|
||||||
|
|
||||||
|
{ok, [#{provider := emqx_authn_redis, state := State}]} =
|
||||||
|
emqx_authentication:list_authenticators(?GLOBAL),
|
||||||
|
|
||||||
Credentials = Credentials0#{
|
Credentials = Credentials0#{
|
||||||
listener => 'tcp:default',
|
listener => 'tcp:default',
|
||||||
protocol => mqtt
|
protocol => mqtt
|
||||||
|
@ -180,6 +183,15 @@ test_user_auth(#{
|
||||||
|
|
||||||
?assertEqual(Result, emqx_access_control:authenticate(Credentials)),
|
?assertEqual(Result, emqx_access_control:authenticate(Credentials)),
|
||||||
|
|
||||||
|
AuthnResult =
|
||||||
|
case Result of
|
||||||
|
{error, _} ->
|
||||||
|
ignore;
|
||||||
|
Any ->
|
||||||
|
Any
|
||||||
|
end,
|
||||||
|
?assertEqual(AuthnResult, emqx_authn_redis:authenticate(Credentials, State)),
|
||||||
|
|
||||||
emqx_authn_test_lib:delete_authenticators(
|
emqx_authn_test_lib:delete_authenticators(
|
||||||
[authentication],
|
[authentication],
|
||||||
?GLOBAL
|
?GLOBAL
|
||||||
|
@ -466,7 +478,7 @@ user_seeds() ->
|
||||||
<<"cmd">> => <<"HMGET mqtt_user:${username} password_hash salt is_superuser">>,
|
<<"cmd">> => <<"HMGET mqtt_user:${username} password_hash salt is_superuser">>,
|
||||||
<<"password_hash_algorithm">> => #{<<"name">> => <<"bcrypt">>}
|
<<"password_hash_algorithm">> => #{<<"name">> => <<"bcrypt">>}
|
||||||
},
|
},
|
||||||
result => {error, bad_username_or_password}
|
result => {error, not_authorized}
|
||||||
},
|
},
|
||||||
|
|
||||||
#{
|
#{
|
||||||
|
|
Loading…
Reference in New Issue