fix: authz headers default value
This commit is contained in:
parent
22e77eff7e
commit
f4f5281b16
|
@ -412,9 +412,22 @@ get_raw_sources() ->
|
||||||
RawSources = emqx:get_raw_config([authorization, sources], []),
|
RawSources = emqx:get_raw_config([authorization, sources], []),
|
||||||
Schema = #{roots => emqx_authz_schema:fields("authorization"), fields => #{}},
|
Schema = #{roots => emqx_authz_schema:fields("authorization"), fields => #{}},
|
||||||
Conf = #{<<"sources">> => RawSources},
|
Conf = #{<<"sources">> => RawSources},
|
||||||
#{<<"sources">> := Sources} = hocon_schema:check_plain(Schema, Conf,
|
#{<<"sources">> := Sources} = hocon_schema:check_plain(Schema, Conf, #{only_fill_defaults => true}),
|
||||||
#{only_fill_defaults => true}),
|
merge_default_headers(Sources).
|
||||||
Sources.
|
|
||||||
|
merge_default_headers(Sources) ->
|
||||||
|
lists:map(fun(Source) ->
|
||||||
|
Convert =
|
||||||
|
case Source of
|
||||||
|
#{<<"method">> := <<"get">>} ->
|
||||||
|
emqx_authz_schema:headers_no_content_type(converter);
|
||||||
|
#{<<"method">> := <<"post">>} ->
|
||||||
|
emqx_authz_schema:headers(converter);
|
||||||
|
_ -> fun(H) -> H end
|
||||||
|
end,
|
||||||
|
Headers = Convert(maps:get(<<"headers">>, Source, #{})),
|
||||||
|
Source#{<<"headers">> => Headers}
|
||||||
|
end, Sources).
|
||||||
|
|
||||||
get_raw_source(Type) ->
|
get_raw_source(Type) ->
|
||||||
lists:filter(fun (#{<<"type">> := T}) ->
|
lists:filter(fun (#{<<"type">> := T}) ->
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
, fields/1
|
, fields/1
|
||||||
, validations/0
|
, validations/0
|
||||||
]).
|
]).
|
||||||
|
-export([
|
||||||
|
headers_no_content_type/1,
|
||||||
|
headers/1
|
||||||
|
]).
|
||||||
|
|
||||||
-import(emqx_schema, [mk_duration/2]).
|
-import(emqx_schema, [mk_duration/2]).
|
||||||
-include_lib("hocon/include/hoconsc.hrl").
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
|
|
Loading…
Reference in New Issue