docs: refine authn and auth config docs
This commit is contained in:
parent
ed073f9966
commit
96de7e6b30
|
@ -63,4 +63,5 @@ do_authorize(ClientInfo, PubSub, Topic) ->
|
||||||
|
|
||||||
-compile({inline, [run_hooks/3]}).
|
-compile({inline, [run_hooks/3]}).
|
||||||
run_hooks(Name, Args, Acc) ->
|
run_hooks(Name, Args, Acc) ->
|
||||||
ok = emqx_metrics:inc(Name), emqx_hooks:run_fold(Name, Args, Acc).
|
ok = emqx_metrics:inc(Name),
|
||||||
|
emqx_hooks:run_fold(Name, Args, Acc).
|
||||||
|
|
|
@ -108,9 +108,27 @@ in <code>zone</code> configs"""
|
||||||
})}
|
})}
|
||||||
, {?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME,
|
, {?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME,
|
||||||
authentication(
|
authentication(
|
||||||
"""Default authentication configs for all MQTT listeners.<br>
|
"""Default authentication configs for all MQTT listeners.
|
||||||
|
<br>
|
||||||
For per-listener overrides see <code>authentication</code>
|
For per-listener overrides see <code>authentication</code>
|
||||||
in listener configs""")}
|
in listener configs
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
EMQ X can be configured with:
|
||||||
|
<br>
|
||||||
|
<ul>
|
||||||
|
<li><code>[]</code>: The default value, it allows *ALL* logins</li>
|
||||||
|
<li>one: For example <code>{enable:true,backend:\"built-in-database\",mechanism=\"password-based\"}</code></li>
|
||||||
|
<li>chain: An array of structs.</li>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
When a chain is configured, the login credentials are checked against the backends
|
||||||
|
per the configured order, until an 'allow' or 'deny' decision can be made.
|
||||||
|
<br>
|
||||||
|
If there is no decision after a full chain exhaustion, the login is rejected.
|
||||||
|
""")}
|
||||||
|
%% NOTE: authorization schema here is only to keep emqx app prue
|
||||||
|
%% the full schema for EMQ X node is injected in emqx_conf_schema.
|
||||||
, {"authorization",
|
, {"authorization",
|
||||||
sc(ref("authorization"),
|
sc(ref("authorization"),
|
||||||
#{})}
|
#{})}
|
||||||
|
|
|
@ -68,8 +68,7 @@ roots() ->
|
||||||
undefined -> persistent_term:put(PtKey, emqx_authn_schema);
|
undefined -> persistent_term:put(PtKey, emqx_authn_schema);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end,
|
end,
|
||||||
%% authorization configs are merged in THIS schema's "authorization" fields
|
emqx_schema_high_prio_roots() ++
|
||||||
lists:keydelete("authorization", 1, emqx_schema:roots(high)) ++
|
|
||||||
[ {"node",
|
[ {"node",
|
||||||
sc(hoconsc:ref("node"),
|
sc(hoconsc:ref("node"),
|
||||||
#{ desc => "Node name, cookie, config & data directories "
|
#{ desc => "Node name, cookie, config & data directories "
|
||||||
|
@ -93,20 +92,6 @@ roots() ->
|
||||||
"should work, but in case you need to do performance "
|
"should work, but in case you need to do performance "
|
||||||
"fine-turning or experiment a bit, this is where to look."
|
"fine-turning or experiment a bit, this is where to look."
|
||||||
})}
|
})}
|
||||||
, {"authorization",
|
|
||||||
sc(hoconsc:ref("authorization"),
|
|
||||||
#{ desc => """
|
|
||||||
Authorization a.k.a ACL.<br>
|
|
||||||
In EMQ X, MQTT client access control is extremly flexible.<br>
|
|
||||||
An out of the box set of authorization data sources are supported.
|
|
||||||
For example,<br>
|
|
||||||
'file' source is to support concise and yet generic ACL rules in a file;<br>
|
|
||||||
'built-in-database' source can be used to store per-client customisable rule sets,
|
|
||||||
natively in the EMQ X node;<br>
|
|
||||||
'http' source to make EMQ X call an external HTTP API to make the decision;<br>
|
|
||||||
'postgresql' etc. to look up clients or rules from external databases;<br>
|
|
||||||
"""
|
|
||||||
})}
|
|
||||||
, {"db",
|
, {"db",
|
||||||
sc(ref("db"),
|
sc(ref("db"),
|
||||||
#{ desc => "Settings of the embedded database."
|
#{ desc => "Settings of the embedded database."
|
||||||
|
@ -849,3 +834,22 @@ ensure_list(V) ->
|
||||||
|
|
||||||
roots(Module) ->
|
roots(Module) ->
|
||||||
lists:map(fun({_BinName, Root}) -> Root end, hocon_schema:roots(Module)).
|
lists:map(fun({_BinName, Root}) -> Root end, hocon_schema:roots(Module)).
|
||||||
|
|
||||||
|
%% Like authentication schema, authorization schema is incomplete in emqx_schema
|
||||||
|
%% module, this function replaces the root filed "authorization" with a new schema
|
||||||
|
emqx_schema_high_prio_roots() ->
|
||||||
|
Roots = emqx_schema:roots(high),
|
||||||
|
Authz = {"authorization",
|
||||||
|
sc(hoconsc:ref("authorization"),
|
||||||
|
#{ desc => """
|
||||||
|
Authorization a.k.a ACL.<br>
|
||||||
|
In EMQ X, MQTT client access control is extremly flexible.<br>
|
||||||
|
An out of the box set of authorization data sources are supported.
|
||||||
|
For example,<br>
|
||||||
|
'file' source is to support concise and yet generic ACL rules in a file;<br>
|
||||||
|
'built-in-database' source can be used to store per-client customisable rule sets,
|
||||||
|
natively in the EMQ X node;<br>
|
||||||
|
'http' source to make EMQ X call an external HTTP API to make the decision;<br>
|
||||||
|
'postgresql' etc. to look up clients or rules from external databases;<br>
|
||||||
|
""" })},
|
||||||
|
lists:keyreplace("authorization", 1, Roots, Authz).
|
||||||
|
|
Loading…
Reference in New Issue