Merge pull request #10733 from thalesmg/fix-pulsar-sensitive-struct-r50
fix(pulsar): mark whole auth struct as sensitive, update dashboard version and improve bridge type matching errors (r5.0)
This commit is contained in:
commit
49424cc9a2
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ endif
|
||||||
# Dashbord version
|
# Dashbord version
|
||||||
# from https://github.com/emqx/emqx-dashboard5
|
# from https://github.com/emqx/emqx-dashboard5
|
||||||
export EMQX_DASHBOARD_VERSION ?= v1.2.4-1
|
export EMQX_DASHBOARD_VERSION ?= v1.2.4-1
|
||||||
export EMQX_EE_DASHBOARD_VERSION ?= e1.0.6
|
export EMQX_EE_DASHBOARD_VERSION ?= e1.0.7-beta.3
|
||||||
|
|
||||||
# `:=` should be used here, otherwise the `$(shell ...)` will be executed every time when the variable is used
|
# `:=` should be used here, otherwise the `$(shell ...)` will be executed every time when the variable is used
|
||||||
# In make 4.4+, for backward-compatibility the value from the original environment is used.
|
# In make 4.4+, for backward-compatibility the value from the original environment is used.
|
||||||
|
|
|
@ -51,11 +51,39 @@ post_request() ->
|
||||||
|
|
||||||
api_schema(Method) ->
|
api_schema(Method) ->
|
||||||
Broker = [
|
Broker = [
|
||||||
ref(Mod, Method)
|
{Type, ref(Mod, Method)}
|
||||||
|| Mod <- [emqx_bridge_webhook_schema, emqx_bridge_mqtt_schema]
|
|| {Type, Mod} <- [
|
||||||
|
{<<"webhook">>, emqx_bridge_webhook_schema},
|
||||||
|
{<<"mqtt">>, emqx_bridge_mqtt_schema}
|
||||||
|
]
|
||||||
],
|
],
|
||||||
EE = ee_api_schemas(Method),
|
EE = ee_api_schemas(Method),
|
||||||
hoconsc:union(Broker ++ EE).
|
hoconsc:union(bridge_api_union(Broker ++ EE)).
|
||||||
|
|
||||||
|
bridge_api_union(Refs) ->
|
||||||
|
Index = maps:from_list(Refs),
|
||||||
|
fun
|
||||||
|
(all_union_members) ->
|
||||||
|
maps:values(Index);
|
||||||
|
({value, V}) ->
|
||||||
|
case V of
|
||||||
|
#{<<"type">> := T} ->
|
||||||
|
case maps:get(T, Index, undefined) of
|
||||||
|
undefined ->
|
||||||
|
throw(#{
|
||||||
|
field_name => type,
|
||||||
|
reason => <<"unknown bridge type">>
|
||||||
|
});
|
||||||
|
Ref ->
|
||||||
|
[Ref]
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
throw(#{
|
||||||
|
field_name => type,
|
||||||
|
reason => <<"unknown bridge type">>
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
-if(?EMQX_RELEASE_EDITION == ee).
|
||||||
ee_api_schemas(Method) ->
|
ee_api_schemas(Method) ->
|
||||||
|
|
|
@ -45,9 +45,19 @@ fields(config) ->
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{authentication,
|
{authentication,
|
||||||
mk(hoconsc:union([none, ref(auth_basic), ref(auth_token)]), #{
|
mk(
|
||||||
default => none, desc => ?DESC("authentication")
|
hoconsc:union(fun auth_union_member_selector/1),
|
||||||
})}
|
#{
|
||||||
|
default => none,
|
||||||
|
%% must mark this whole union as sensitive because
|
||||||
|
%% hocon ignores the `sensitive' metadata in struct
|
||||||
|
%% fields... Also, when trying to type check a struct
|
||||||
|
%% that doesn't match the intended type, it won't have
|
||||||
|
%% sensitivity information from sibling types.
|
||||||
|
sensitive => true,
|
||||||
|
desc => ?DESC("authentication")
|
||||||
|
}
|
||||||
|
)}
|
||||||
] ++ emqx_connector_schema_lib:ssl_fields();
|
] ++ emqx_connector_schema_lib:ssl_fields();
|
||||||
fields(producer_opts) ->
|
fields(producer_opts) ->
|
||||||
[
|
[
|
||||||
|
@ -226,3 +236,21 @@ override_default(OriginalFn, NewDefault) ->
|
||||||
(default) -> NewDefault;
|
(default) -> NewDefault;
|
||||||
(Field) -> OriginalFn(Field)
|
(Field) -> OriginalFn(Field)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
auth_union_member_selector(all_union_members) ->
|
||||||
|
[none, ref(auth_basic), ref(auth_token)];
|
||||||
|
auth_union_member_selector({value, V}) ->
|
||||||
|
case V of
|
||||||
|
#{<<"password">> := _} ->
|
||||||
|
[ref(auth_basic)];
|
||||||
|
#{<<"jwt">> := _} ->
|
||||||
|
[ref(auth_token)];
|
||||||
|
<<"none">> ->
|
||||||
|
[none];
|
||||||
|
_ ->
|
||||||
|
Expected = "none | basic | token",
|
||||||
|
throw(#{
|
||||||
|
field_name => authentication,
|
||||||
|
expected => Expected
|
||||||
|
})
|
||||||
|
end.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_ee_bridge, [
|
{application, emqx_ee_bridge, [
|
||||||
{description, "EMQX Enterprise data bridges"},
|
{description, "EMQX Enterprise data bridges"},
|
||||||
{vsn, "0.1.12"},
|
{vsn, "0.1.13"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
||||||
|
|
|
@ -14,33 +14,37 @@
|
||||||
|
|
||||||
api_schemas(Method) ->
|
api_schemas(Method) ->
|
||||||
[
|
[
|
||||||
ref(emqx_bridge_gcp_pubsub, Method),
|
%% We need to map the `type' field of a request (binary) to a
|
||||||
ref(emqx_bridge_kafka, Method ++ "_consumer"),
|
%% bridge schema module.
|
||||||
ref(emqx_bridge_kafka, Method ++ "_producer"),
|
api_ref(emqx_bridge_gcp_pubsub, <<"gcp_pubsub">>, Method),
|
||||||
ref(emqx_bridge_cassandra, Method),
|
api_ref(emqx_bridge_kafka, <<"kafka_consumer">>, Method ++ "_consumer"),
|
||||||
ref(emqx_ee_bridge_mysql, Method),
|
%% TODO: rename this to `kafka_producer' after alias support is added
|
||||||
ref(emqx_bridge_pgsql, Method),
|
%% to hocon; keeping this as just `kafka' for backwards compatibility.
|
||||||
ref(emqx_ee_bridge_mongodb, Method ++ "_rs"),
|
api_ref(emqx_bridge_kafka, <<"kafka">>, Method ++ "_producer"),
|
||||||
ref(emqx_ee_bridge_mongodb, Method ++ "_sharded"),
|
api_ref(emqx_bridge_cassandra, <<"cassandra">>, Method),
|
||||||
ref(emqx_ee_bridge_mongodb, Method ++ "_single"),
|
api_ref(emqx_ee_bridge_mysql, <<"mysql">>, Method),
|
||||||
ref(emqx_ee_bridge_hstreamdb, Method),
|
api_ref(emqx_bridge_pgsql, <<"pgsql">>, Method),
|
||||||
ref(emqx_bridge_influxdb, Method ++ "_api_v1"),
|
api_ref(emqx_ee_bridge_mongodb, <<"mongodb_rs">>, Method ++ "_rs"),
|
||||||
ref(emqx_bridge_influxdb, Method ++ "_api_v2"),
|
api_ref(emqx_ee_bridge_mongodb, <<"mongodb_sharded">>, Method ++ "_sharded"),
|
||||||
ref(emqx_ee_bridge_redis, Method ++ "_single"),
|
api_ref(emqx_ee_bridge_mongodb, <<"mongodb_single">>, Method ++ "_single"),
|
||||||
ref(emqx_ee_bridge_redis, Method ++ "_sentinel"),
|
api_ref(emqx_ee_bridge_hstreamdb, <<"hstreamdb">>, Method),
|
||||||
ref(emqx_ee_bridge_redis, Method ++ "_cluster"),
|
api_ref(emqx_bridge_influxdb, <<"influxdb_api_v1">>, Method ++ "_api_v1"),
|
||||||
ref(emqx_bridge_timescale, Method),
|
api_ref(emqx_bridge_influxdb, <<"influxdb_api_v2">>, Method ++ "_api_v2"),
|
||||||
ref(emqx_bridge_matrix, Method),
|
api_ref(emqx_ee_bridge_redis, <<"redis_single">>, Method ++ "_single"),
|
||||||
ref(emqx_bridge_tdengine, Method),
|
api_ref(emqx_ee_bridge_redis, <<"redis_sentinel">>, Method ++ "_sentinel"),
|
||||||
ref(emqx_ee_bridge_clickhouse, Method),
|
api_ref(emqx_ee_bridge_redis, <<"redis_cluster">>, Method ++ "_cluster"),
|
||||||
ref(emqx_bridge_dynamo, Method),
|
api_ref(emqx_bridge_timescale, <<"timescale">>, Method),
|
||||||
ref(emqx_bridge_rocketmq, Method),
|
api_ref(emqx_bridge_matrix, <<"matrix">>, Method),
|
||||||
ref(emqx_bridge_sqlserver, Method),
|
api_ref(emqx_bridge_tdengine, <<"tdengine">>, Method),
|
||||||
ref(emqx_bridge_opents, Method),
|
api_ref(emqx_ee_bridge_clickhouse, <<"clickhouse">>, Method),
|
||||||
ref(emqx_bridge_pulsar, Method ++ "_producer"),
|
api_ref(emqx_bridge_dynamo, <<"dynamo">>, Method),
|
||||||
ref(emqx_bridge_oracle, Method),
|
api_ref(emqx_bridge_rocketmq, <<"rocketmq">>, Method),
|
||||||
ref(emqx_bridge_iotdb, Method),
|
api_ref(emqx_bridge_sqlserver, <<"sqlserver">>, Method),
|
||||||
ref(emqx_bridge_rabbitmq, Method)
|
api_ref(emqx_bridge_opents, <<"opents">>, Method),
|
||||||
|
api_ref(emqx_bridge_pulsar, <<"pulsar_producer">>, Method ++ "_producer"),
|
||||||
|
api_ref(emqx_bridge_oracle, <<"oracle">>, Method),
|
||||||
|
api_ref(emqx_bridge_iotdb, <<"iotdb">>, Method),
|
||||||
|
api_ref(emqx_bridge_rabbitmq, <<"rabbitmq">>, Method)
|
||||||
].
|
].
|
||||||
|
|
||||||
schema_modules() ->
|
schema_modules() ->
|
||||||
|
@ -338,3 +342,6 @@ rabbitmq_structs() ->
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
api_ref(Module, Type, Method) ->
|
||||||
|
{Type, ref(Module, Method)}.
|
||||||
|
|
Loading…
Reference in New Issue