refactor: move schema injection from hrl to erl
This commit is contained in:
parent
a53fa977df
commit
54fc605cc5
|
@ -37,47 +37,4 @@
|
||||||
|
|
||||||
-define(READONLY_KEYS, [cluster, rpc, node]).
|
-define(READONLY_KEYS, [cluster, rpc, node]).
|
||||||
|
|
||||||
-define(CE_AUTHZ_SOURCE_SCHEMA_MODS, [
|
|
||||||
emqx_authz_file_schema,
|
|
||||||
emqx_authz_mnesia_schema,
|
|
||||||
emqx_authz_http_schema,
|
|
||||||
emqx_authz_redis_schema,
|
|
||||||
emqx_authz_mysql_schema,
|
|
||||||
emqx_authz_postgresql_schema,
|
|
||||||
emqx_authz_mongodb_schema,
|
|
||||||
emqx_authz_ldap_schema
|
|
||||||
]).
|
|
||||||
|
|
||||||
-define(EE_AUTHZ_SOURCE_SCHEMA_MODS, []).
|
|
||||||
|
|
||||||
-define(CE_AUTHN_PROVIDER_SCHEMA_MODS, [
|
|
||||||
emqx_authn_mnesia_schema,
|
|
||||||
emqx_authn_mysql_schema,
|
|
||||||
emqx_authn_postgresql_schema,
|
|
||||||
emqx_authn_mongodb_schema,
|
|
||||||
emqx_authn_redis_schema,
|
|
||||||
emqx_authn_http_schema,
|
|
||||||
emqx_authn_jwt_schema,
|
|
||||||
emqx_authn_scram_mnesia_schema,
|
|
||||||
emqx_authn_ldap_schema
|
|
||||||
]).
|
|
||||||
|
|
||||||
-define(EE_AUTHN_PROVIDER_SCHEMA_MODS, [
|
|
||||||
emqx_gcp_device_authn_schema
|
|
||||||
]).
|
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
|
||||||
|
|
||||||
-define(AUTHZ_SOURCE_SCHEMA_MODS, ?CE_AUTHZ_SOURCE_SCHEMA_MODS ++ ?EE_AUTHZ_SOURCE_SCHEMA_MODS).
|
|
||||||
-define(AUTHN_PROVIDER_SCHEMA_MODS,
|
|
||||||
(?CE_AUTHN_PROVIDER_SCHEMA_MODS ++ ?EE_AUTHN_PROVIDER_SCHEMA_MODS)
|
|
||||||
).
|
|
||||||
|
|
||||||
-else.
|
|
||||||
|
|
||||||
-define(AUTHZ_SOURCE_SCHEMA_MODS, ?CE_AUTHZ_SOURCE_SCHEMA_MODS).
|
|
||||||
-define(AUTHN_PROVIDER_SCHEMA_MODS, ?CE_AUTHN_PROVIDER_SCHEMA_MODS).
|
|
||||||
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-endif.
|
-endif.
|
||||||
|
|
|
@ -71,20 +71,6 @@
|
||||||
emqx_mgmt_api_key_schema
|
emqx_mgmt_api_key_schema
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-define(AUTH_EXT_SCHEMA_MODS, [emqx_auth_ext_schema]).
|
|
||||||
|
|
||||||
-if(defined(EMQX_RELEASE_EDITION) andalso ?EMQX_RELEASE_EDITION == ee).
|
|
||||||
-define(OTHER_INJECTING_CONFIGS, ?AUTH_EXT_SCHEMA_MODS).
|
|
||||||
-else.
|
|
||||||
-define(OTHER_INJECTING_CONFIGS, []).
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
-define(INJECTING_CONFIGS, [
|
|
||||||
{emqx_authn_schema, ?AUTHN_PROVIDER_SCHEMA_MODS},
|
|
||||||
{emqx_authz_schema, ?AUTHZ_SOURCE_SCHEMA_MODS}
|
|
||||||
| ?OTHER_INJECTING_CONFIGS
|
|
||||||
]).
|
|
||||||
|
|
||||||
%% 1 million default ports counter
|
%% 1 million default ports counter
|
||||||
-define(DEFAULT_MAX_PORTS, 1024 * 1024).
|
-define(DEFAULT_MAX_PORTS, 1024 * 1024).
|
||||||
|
|
||||||
|
@ -108,7 +94,8 @@ tags() ->
|
||||||
[<<"EMQX">>].
|
[<<"EMQX">>].
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
ok = emqx_schema_hooks:inject_from_modules(?INJECTING_CONFIGS),
|
Injections = emqx_conf_schema_inject:schemas(),
|
||||||
|
ok = emqx_schema_hooks:inject_from_modules(Injections),
|
||||||
emqx_schema_high_prio_roots() ++
|
emqx_schema_high_prio_roots() ++
|
||||||
[
|
[
|
||||||
{node,
|
{node,
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
|
%%
|
||||||
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
%% you may not use this file except in compliance with the License.
|
||||||
|
%% You may obtain a copy of the License at
|
||||||
|
%%
|
||||||
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
%%
|
||||||
|
%% Unless required by applicable law or agreed to in writing, software
|
||||||
|
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
%% See the License for the specific language governing permissions and
|
||||||
|
%% limitations under the License.
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(emqx_conf_schema_inject).
|
||||||
|
|
||||||
|
-export([schemas/0]).
|
||||||
|
|
||||||
|
schemas() ->
|
||||||
|
schemas(emqx_release:edition()).
|
||||||
|
|
||||||
|
schemas(Edition) ->
|
||||||
|
auth_ext(Edition) ++
|
||||||
|
authn(Edition) ++
|
||||||
|
authz() ++
|
||||||
|
customized().
|
||||||
|
|
||||||
|
auth_ext(ce) ->
|
||||||
|
[];
|
||||||
|
auth_ext(ee) ->
|
||||||
|
[emqx_auth_ext_schema].
|
||||||
|
|
||||||
|
authn(Edition) ->
|
||||||
|
[{emqx_authn_schema, authn_mods(Edition)}].
|
||||||
|
|
||||||
|
authn_mods(ce) ->
|
||||||
|
[
|
||||||
|
emqx_authn_mnesia_schema,
|
||||||
|
emqx_authn_mysql_schema,
|
||||||
|
emqx_authn_postgresql_schema,
|
||||||
|
emqx_authn_mongodb_schema,
|
||||||
|
emqx_authn_redis_schema,
|
||||||
|
emqx_authn_http_schema,
|
||||||
|
emqx_authn_jwt_schema,
|
||||||
|
emqx_authn_scram_mnesia_schema,
|
||||||
|
emqx_authn_ldap_schema
|
||||||
|
];
|
||||||
|
authn_mods(ee) ->
|
||||||
|
authn_mods(ce) ++
|
||||||
|
[emqx_gcp_device_authn_schema].
|
||||||
|
|
||||||
|
authz() ->
|
||||||
|
[{emqx_authz_schema, authz_mods()}].
|
||||||
|
|
||||||
|
authz_mods() ->
|
||||||
|
[
|
||||||
|
emqx_authz_file_schema,
|
||||||
|
emqx_authz_mnesia_schema,
|
||||||
|
emqx_authz_http_schema,
|
||||||
|
emqx_authz_redis_schema,
|
||||||
|
emqx_authz_mysql_schema,
|
||||||
|
emqx_authz_postgresql_schema,
|
||||||
|
emqx_authz_mongodb_schema,
|
||||||
|
emqx_authz_ldap_schema
|
||||||
|
].
|
||||||
|
|
||||||
|
%% Add more schemas here.
|
||||||
|
customized() ->
|
||||||
|
[].
|
Loading…
Reference in New Issue