refactor(authn): make schema doc generation work
This commit is contained in:
parent
efca545d3d
commit
2f2a093150
|
@ -1355,11 +1355,12 @@ str(S) when is_list(S) ->
|
||||||
S.
|
S.
|
||||||
|
|
||||||
authentication(Desc) ->
|
authentication(Desc) ->
|
||||||
#{ type => hoconsc:union([typerefl:map(), hoconsc:array(typerefl:map())])
|
#{ type => hoconsc:lazy(hoconsc:union([typerefl:map(), hoconsc:array(typerefl:map())]))
|
||||||
, desc => [Desc, "<br>", """
|
, desc => iolist_to_binary([Desc, "<br>", """
|
||||||
Authentication can be one single authenticator instance or a chain of authenticators as an array.
|
Authentication can be one single authenticator instance or a chain of authenticators as an array.
|
||||||
The when authenticating a login (username, client ID, etc.) the authenticators are checked
|
The when authenticating a login (username, client ID, etc.) the authenticators are checked
|
||||||
in the configured order.
|
in the configured order.<br>
|
||||||
"""
|
EMQ X comes with a set of pre-built autenticators, for more details, see
|
||||||
]
|
<code>authenticator_config</code>.
|
||||||
|
"""])
|
||||||
}.
|
}.
|
||||||
|
|
|
@ -23,8 +23,10 @@
|
||||||
, fields/1
|
, fields/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% just a stub, never used at root level
|
%% only for doc generation
|
||||||
roots() -> [].
|
roots() -> [{authenticator_config,
|
||||||
|
#{type => hoconsc:union(config_refs([Module || {_AuthnType, Module} <- emqx_authn:providers()]))
|
||||||
|
}}].
|
||||||
|
|
||||||
fields(_) -> [].
|
fields(_) -> [].
|
||||||
|
|
||||||
|
@ -35,3 +37,6 @@ common_fields() ->
|
||||||
enable(type) -> boolean();
|
enable(type) -> boolean();
|
||||||
enable(default) -> true;
|
enable(default) -> true;
|
||||||
enable(_) -> undefined.
|
enable(_) -> undefined.
|
||||||
|
|
||||||
|
config_refs(Modules) ->
|
||||||
|
lists:append([Module:refs() || Module <- Modules]).
|
||||||
|
|
|
@ -40,12 +40,11 @@
|
||||||
%% Hocon Schema
|
%% Hocon Schema
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace() -> "authn-password_based-http_server".
|
namespace() -> "authn-http".
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
[ {config, {union, [ hoconsc:ref(?MODULE, get)
|
[ {config, hoconsc:mk(hoconsc:union(refs()),
|
||||||
, hoconsc:ref(?MODULE, post)
|
#{})}
|
||||||
]}}
|
|
||||||
].
|
].
|
||||||
|
|
||||||
fields(get) ->
|
fields(get) ->
|
||||||
|
@ -61,8 +60,8 @@ fields(post) ->
|
||||||
] ++ common_fields().
|
] ++ common_fields().
|
||||||
|
|
||||||
common_fields() ->
|
common_fields() ->
|
||||||
[ {mechanism, 'password-based'}
|
[ {mechanism, hoconsc:enum(['password-based'])}
|
||||||
, {backend, 'http'}
|
, {backend, hoconsc:enum(['http'])}
|
||||||
, {url, fun url/1}
|
, {url, fun url/1}
|
||||||
, {body, fun body/1}
|
, {body, fun body/1}
|
||||||
, {request_timeout, fun request_timeout/1}
|
, {request_timeout, fun request_timeout/1}
|
||||||
|
|
|
@ -40,10 +40,9 @@
|
||||||
namespace() -> "authn-jwt".
|
namespace() -> "authn-jwt".
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
[ {config, {union, [ hoconsc:mk('hmac-based')
|
[ {config, hoconsc:mk(hoconsc:union(refs()),
|
||||||
, hoconsc:mk('public-key')
|
#{}
|
||||||
, hoconsc:mk('jwks')
|
)}
|
||||||
]}}
|
|
||||||
].
|
].
|
||||||
|
|
||||||
fields('hmac-based') ->
|
fields('hmac-based') ->
|
||||||
|
|
|
@ -80,7 +80,7 @@ mnesia(boot) ->
|
||||||
%% Hocon Schema
|
%% Hocon Schema
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace() -> "authn-password_based-builtin_db".
|
namespace() -> "authn-builtin_db".
|
||||||
|
|
||||||
roots() -> [config].
|
roots() -> [config].
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,11 @@
|
||||||
%% Hocon Schema
|
%% Hocon Schema
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace() -> "authn-password_based-mongodb".
|
namespace() -> "authn-mongodb".
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
[ {config, {union, [ hoconsc:mk(standalone)
|
[ {config, hoconsc:mk(hoconsc:union(refs()),
|
||||||
, hoconsc:mk('replica-set')
|
#{})}
|
||||||
, hoconsc:mk('sharded-cluster')
|
|
||||||
]}}
|
|
||||||
].
|
].
|
||||||
|
|
||||||
fields(standalone) ->
|
fields(standalone) ->
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
%% Hocon Schema
|
%% Hocon Schema
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace() -> "authn-password_based-mysql".
|
namespace() -> "authn-mysql".
|
||||||
|
|
||||||
roots() -> [config].
|
roots() -> [config].
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
%% Hocon Schema
|
%% Hocon Schema
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace() -> "authn-password_based-postgresql".
|
namespace() -> "authn-postgresql".
|
||||||
|
|
||||||
roots() -> [config].
|
roots() -> [config].
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,11 @@
|
||||||
%% Hocon Schema
|
%% Hocon Schema
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace() -> "authn-password_based-redis".
|
namespace() -> "authn-redis".
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
[ {config, {union, [ hoconsc:mk(standalone)
|
[ {config, hoconsc:mk(hoconsc:union(refs()),
|
||||||
, hoconsc:mk(cluster)
|
#{})}
|
||||||
, hoconsc:mk(sentinel)
|
|
||||||
]}}
|
|
||||||
].
|
].
|
||||||
|
|
||||||
fields(standalone) ->
|
fields(standalone) ->
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
[ emqx_bridge_schema
|
[ emqx_bridge_schema
|
||||||
, emqx_retainer_schema
|
, emqx_retainer_schema
|
||||||
, emqx_statsd_schema
|
, emqx_statsd_schema
|
||||||
|
, emqx_authn_schema
|
||||||
, emqx_authz_schema
|
, emqx_authz_schema
|
||||||
, emqx_auto_subscribe_schema
|
, emqx_auto_subscribe_schema
|
||||||
, emqx_modules_schema
|
, emqx_modules_schema
|
||||||
|
|
Loading…
Reference in New Issue