fix(emqx_authz_api_mnesia): return the right matchers
This commit is contained in:
parent
dbdb78d38a
commit
6ee475d9b1
|
@ -578,13 +578,19 @@ purge(delete, _) ->
|
|||
%%--------------------------------------------------------------------
|
||||
%% QueryString to MatchSpec
|
||||
|
||||
-spec query_username(atom(), {list(), list()}) -> {ets:match_spec(), fun() | undefined}.
|
||||
-spec query_username(atom(), {list(), list()}) -> emqx_mgmt_api:match_spec_and_filter().
|
||||
query_username(_Tab, {_QString, FuzzyQString}) ->
|
||||
{emqx_authz_mnesia:list_username_rules(), fuzzy_filter_fun(FuzzyQString)}.
|
||||
#{
|
||||
match_spec => emqx_authz_mnesia:list_username_rules(),
|
||||
fuzzy_fun => fuzzy_filter_fun(FuzzyQString)
|
||||
}.
|
||||
|
||||
-spec query_clientid(atom(), {list(), list()}) -> {ets:match_spec(), fun() | undefined}.
|
||||
-spec query_clientid(atom(), {list(), list()}) -> emqx_mgmt_api:match_spec_and_filter().
|
||||
query_clientid(_Tab, {_QString, FuzzyQString}) ->
|
||||
{emqx_authz_mnesia:list_clientid_rules(), fuzzy_filter_fun(FuzzyQString)}.
|
||||
#{
|
||||
match_spec => emqx_authz_mnesia:list_clientid_rules(),
|
||||
fuzzy_fun => fuzzy_filter_fun(FuzzyQString)
|
||||
}.
|
||||
|
||||
%% Fuzzy username funcs
|
||||
fuzzy_filter_fun([]) ->
|
||||
|
|
|
@ -35,6 +35,28 @@
|
|||
b2i/1
|
||||
]).
|
||||
|
||||
-export_type([
|
||||
match_spec_and_filter/0
|
||||
]).
|
||||
|
||||
-type query_params() :: list() | map().
|
||||
|
||||
-type query_schema() :: [
|
||||
{Key :: binary(), Type :: atom | binary | integer | timestamp | ip | ip_port}
|
||||
].
|
||||
|
||||
-type query_to_match_spec_fun() :: fun((list(), list()) -> match_spec_and_filter()).
|
||||
|
||||
-type match_spec_and_filter() :: #{match_spec := ets:match_spec(), fuzzy_fun := fuzzy_filter_fun()}.
|
||||
|
||||
-type fuzzy_filter_fun() :: undefined | {fun(), list()}.
|
||||
|
||||
-type format_result_fun() ::
|
||||
fun((node(), term()) -> term())
|
||||
| fun((term()) -> term()).
|
||||
|
||||
-type query_return() :: #{meta := map(), data := [term()]}.
|
||||
|
||||
-export([do_query/2, apply_total_query/1]).
|
||||
|
||||
paginate(Tables, Params, {Module, FormatFun}) ->
|
||||
|
@ -121,24 +143,6 @@ limit(Params) ->
|
|||
%% Node Query
|
||||
%%--------------------------------------------------------------------
|
||||
|
||||
-type query_params() :: list() | map().
|
||||
|
||||
-type query_schema() :: [
|
||||
{Key :: binary(), Type :: atom | binary | integer | timestamp | ip | ip_port}
|
||||
].
|
||||
|
||||
-type query_to_match_spec_fun() :: fun((list(), list()) -> match_spec_and_filter()).
|
||||
|
||||
-type match_spec_and_filter() :: #{match_spec := ets:match_spec(), fuzzy_fun := fuzzy_filter_fun()}.
|
||||
|
||||
-type fuzzy_filter_fun() :: undefined | {fun(), list()}.
|
||||
|
||||
-type format_result_fun() ::
|
||||
fun((node(), term()) -> term())
|
||||
| fun((term()) -> term()).
|
||||
|
||||
-type query_return() :: #{meta := map(), data := [term()]}.
|
||||
|
||||
-spec node_query(
|
||||
node(),
|
||||
atom(),
|
||||
|
|
Loading…
Reference in New Issue