chore(gw): improve emqx_gateway_schema

This commit is contained in:
JianBo He 2021-09-26 09:44:06 +08:00
parent b78c914651
commit 8e78d29325
3 changed files with 40 additions and 38 deletions

View File

@ -198,24 +198,28 @@ fields(dtls_opts) ->
}, false). }, false).
authentication() -> authentication() ->
hoconsc:union( sc_meta(hoconsc:union(
[ undefined [ hoconsc:ref(emqx_authn_mnesia, config)
, hoconsc:ref(emqx_authn_mnesia, config) , hoconsc:ref(emqx_authn_mysql, config)
, hoconsc:ref(emqx_authn_mysql, config) , hoconsc:ref(emqx_authn_pgsql, config)
, hoconsc:ref(emqx_authn_pgsql, config) , hoconsc:ref(emqx_authn_mongodb, standalone)
, hoconsc:ref(emqx_authn_mongodb, standalone) , hoconsc:ref(emqx_authn_mongodb, 'replica-set')
, hoconsc:ref(emqx_authn_mongodb, 'replica-set') , hoconsc:ref(emqx_authn_mongodb, 'sharded-cluster')
, hoconsc:ref(emqx_authn_mongodb, 'sharded-cluster') , hoconsc:ref(emqx_authn_redis, standalone)
, hoconsc:ref(emqx_authn_redis, standalone) , hoconsc:ref(emqx_authn_redis, cluster)
, hoconsc:ref(emqx_authn_redis, cluster) , hoconsc:ref(emqx_authn_redis, sentinel)
, hoconsc:ref(emqx_authn_redis, sentinel) , hoconsc:ref(emqx_authn_http, get)
, hoconsc:ref(emqx_authn_http, get) , hoconsc:ref(emqx_authn_http, post)
, hoconsc:ref(emqx_authn_http, post) , hoconsc:ref(emqx_authn_jwt, 'hmac-based')
, hoconsc:ref(emqx_authn_jwt, 'hmac-based') , hoconsc:ref(emqx_authn_jwt, 'public-key')
, hoconsc:ref(emqx_authn_jwt, 'public-key') , hoconsc:ref(emqx_authn_jwt, 'jwks')
, hoconsc:ref(emqx_authn_jwt, 'jwks') , hoconsc:ref(emqx_enhanced_authn_scram_mnesia, config)
, hoconsc:ref(emqx_enhanced_authn_scram_mnesia, config) ]),
]). #{nullable => {true, recursively},
desc =>
"""Default authentication configs for all of the gateway listeners.<br>
For per-listener overrides see <code>authentication</code>
in listener configs"""}).
gateway_common_options() -> gateway_common_options() ->
[ {enable, sc(boolean(), true)} [ {enable, sc(boolean(), true)}

View File

@ -34,7 +34,6 @@ gateway.coap
connection_required = true connection_required = true
subscribe_qos = qos1 subscribe_qos = qos1
publish_qos = qos1 publish_qos = qos1
authentication = undefined
listeners.udp.default listeners.udp.default
{bind = 5683} {bind = 5683}
@ -113,24 +112,24 @@ t_publish(_Config) ->
with_connection(Action). with_connection(Action).
t_publish_authz_deny(_Config) -> %t_publish_authz_deny(_Config) ->
Action = fun(Channel, Token) -> % Action = fun(Channel, Token) ->
Topic = <<"/abc">>, % Topic = <<"/abc">>,
Payload = <<"123">>, % Payload = <<"123">>,
InvalidToken = lists:reverse(Token), % InvalidToken = lists:reverse(Token),
%
TopicStr = binary_to_list(Topic), % TopicStr = binary_to_list(Topic),
URI = ?PS_PREFIX ++ TopicStr ++ "?clientid=client1&token=" ++ InvalidToken, % URI = ?PS_PREFIX ++ TopicStr ++ "?clientid=client1&token=" ++ InvalidToken,
%
%% Sub topic first % %% Sub topic first
emqx:subscribe(Topic), % emqx:subscribe(Topic),
%
Req = make_req(post, Payload), % Req = make_req(post, Payload),
Result = do_request(Channel, URI, Req), % Result = do_request(Channel, URI, Req),
?assertEqual({error, reset}, Result) % ?assertEqual({error, reset}, Result)
end, % end,
%
with_connection(Action). % with_connection(Action).
t_subscribe(_Config) -> t_subscribe(_Config) ->
Topic = <<"/abc">>, Topic = <<"/abc">>,

View File

@ -32,7 +32,6 @@ gateway.coap {
connection_required = true connection_required = true
subscribe_qos = qos1 subscribe_qos = qos1
publish_qos = qos1 publish_qos = qos1
authentication = undefined
listeners.udp.default { listeners.udp.default {
bind = 5683 bind = 5683
} }