Merge pull request #9299 from sstrigler/authz-api-fixes
Authz API fixes
This commit is contained in:
commit
6515032e06
|
@ -1,7 +1,7 @@
|
|||
%% -*- mode: erlang -*-
|
||||
{application, emqx_authz, [
|
||||
{description, "An OTP application"},
|
||||
{vsn, "0.1.6"},
|
||||
{vsn, "0.1.7"},
|
||||
{registered, []},
|
||||
{mod, {emqx_authz_app, []}},
|
||||
{applications, [
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
-export([
|
||||
api_spec/0,
|
||||
paths/0,
|
||||
schema/1
|
||||
schema/1,
|
||||
fields/1
|
||||
]).
|
||||
|
||||
-export([
|
||||
|
@ -63,6 +64,9 @@ paths() ->
|
|||
"/authorization/sources/:type/move"
|
||||
].
|
||||
|
||||
fields(sources) ->
|
||||
[{sources, mk(array(hoconsc:union(authz_sources_type_refs())), #{desc => ?DESC(sources)})}].
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% Schema for each URI
|
||||
%%--------------------------------------------------------------------
|
||||
|
@ -75,10 +79,7 @@ schema("/authorization/sources") ->
|
|||
tags => ?TAGS,
|
||||
responses =>
|
||||
#{
|
||||
200 => mk(
|
||||
array(hoconsc:union(authz_sources_type_refs())),
|
||||
#{desc => ?DESC(sources)}
|
||||
)
|
||||
200 => ref(?MODULE, sources)
|
||||
}
|
||||
},
|
||||
post =>
|
||||
|
@ -241,7 +242,7 @@ source(Method, #{bindings := #{type := Type} = Bindings} = Req) when
|
|||
source(get, #{bindings := #{type := Type}}) ->
|
||||
case get_raw_source(Type) of
|
||||
[] ->
|
||||
{404, #{message => <<"Not found ", Type/binary>>}};
|
||||
{404, #{code => <<"NOT_FOUND">>, message => <<"Not found: ", Type/binary>>}};
|
||||
[#{<<"type">> := <<"file">>, <<"enable">> := Enable, <<"path">> := Path}] ->
|
||||
case file:read_file(Path) of
|
||||
{ok, Rules} ->
|
||||
|
|
|
@ -181,6 +181,12 @@ t_api(_) ->
|
|||
{ok, 200, Result1} = request(get, uri(["authorization", "sources"]), []),
|
||||
?assertEqual([], get_sources(Result1)),
|
||||
|
||||
{ok, 404, ErrResult} = request(get, uri(["authorization", "sources", "http"]), []),
|
||||
?assertMatch(
|
||||
#{<<"code">> := <<"NOT_FOUND">>, <<"message">> := <<"Not found: http">>},
|
||||
jsx:decode(ErrResult)
|
||||
),
|
||||
|
||||
[
|
||||
begin
|
||||
{ok, 204, _} = request(post, uri(["authorization", "sources"]), Source)
|
||||
|
|
|
@ -37,4 +37,8 @@
|
|||
- Fix incorrect topic authorize checking of delayed messages [#9290](https://github.com/emqx/emqx/pull/9290).
|
||||
Now will determine the actual topic of the delayed messages, e.g. `$delayed/1/t/foo` will be treated as `t/foo` in authorize checks.
|
||||
|
||||
- Add property `code` to error response for `/authentication/sources/:type` [9299](https://github.com/emqx/emqx/pull/9299).
|
||||
|
||||
- Align documentation for `/authentication/sources` with what we actually send [9299](https://github.com/emqx/emqx/pull/9299).
|
||||
|
||||
- Fix query string parameter 'node' to `/configs` resource being ignored, return 404 if node does not exist [#9310](https://github.com/emqx/emqx/pull/9310/).
|
|
@ -35,4 +35,9 @@
|
|||
- 修复延迟消息的主题授权判断不正确的问题 [#9290](https://github.com/emqx/emqx/pull/9290)。
|
||||
现在将会对延迟消息中的真实主题进行授权判断,比如,`$delayed/1/t/foo` 会被当作 `t/foo` 进行判断。
|
||||
|
||||
- 修复 `/configs` API 的 'node' 参数的问题,如果节点不存在,则返回 HTTP 状态码 404
|
||||
|
||||
- 为 API `/authentication/sources/:type` 的返回值增加 `code` 字段 [9299](https://github.com/emqx/emqx/pull/9299)。
|
||||
|
||||
- 对齐文档,`/authentication/sources` 接口的文档仅列出已经支持的资源 [9299](https://github.com/emqx/emqx/pull/9299)。
|
||||
|
||||
- 修复 `/configs` API 的 'node' 参数的问题,如果节点不存在,则返回 HTTP 状态码 404 [#9310](https://github.com/emqx/emqx/pull/9310/)。
|
Loading…
Reference in New Issue