From 4594d2d42bea9ab1e4b7fd8c64111b28f0c96d35 Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Wed, 25 Aug 2021 16:09:54 +0800 Subject: [PATCH] chore(authorization): merge authorization in emqx and emqx_authz --- apps/emqx_authz/etc/emqx_authz.conf | 10 +++++----- apps/emqx_authz/src/emqx_authz_schema.erl | 4 ++-- apps/emqx_machine/src/emqx_machine_schema.erl | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/emqx_authz/etc/emqx_authz.conf b/apps/emqx_authz/etc/emqx_authz.conf index 5928b1f97..be05437c0 100644 --- a/apps/emqx_authz/etc/emqx_authz.conf +++ b/apps/emqx_authz/etc/emqx_authz.conf @@ -1,9 +1,5 @@ -authorization_rules { +authorization { rules = [ - # { - # type: file - # path: {{ platform_etc_dir }}/authorization_rules.conf - # }, # { # type: http # config: { @@ -68,6 +64,10 @@ authorization_rules { # } # collection: mqtt_authz # find: { "$or": [ { "username": "%u" }, { "clientid": "%c" } ] } + # }, + # { + # type: file + # path: {{ platform_etc_dir }}/authorization_rules.conf # } ] } diff --git a/apps/emqx_authz/src/emqx_authz_schema.erl b/apps/emqx_authz/src/emqx_authz_schema.erl index a09046572..9de963972 100644 --- a/apps/emqx_authz/src/emqx_authz_schema.erl +++ b/apps/emqx_authz/src/emqx_authz_schema.erl @@ -17,9 +17,9 @@ , fields/1 ]). -structs() -> ["authorization_rules"]. +structs() -> ["authorization"]. -fields("authorization_rules") -> +fields("authorization") -> [ {rules, rules()} ]; fields(file) -> diff --git a/apps/emqx_machine/src/emqx_machine_schema.erl b/apps/emqx_machine/src/emqx_machine_schema.erl index a8cba047d..ac21ed56e 100644 --- a/apps/emqx_machine/src/emqx_machine_schema.erl +++ b/apps/emqx_machine/src/emqx_machine_schema.erl @@ -197,6 +197,10 @@ fields("log_burst_limit") -> , {"window_time", t(emqx_schema:duration(), undefined, "1s")} ]; +fields("authorization") -> + emqx_schema:fields("authorization") ++ + emqx_authz_schema:fields("authorization"); + fields(Name) -> find_field(Name, ?MERGED_CONFIGS).