fix(s3): mark S3 secrets as `sensitive` in schema
This commit is contained in:
parent
04523b3f81
commit
f06300cbed
|
@ -12,6 +12,7 @@
|
||||||
-export([roots/0, fields/1, namespace/0, tags/0, desc/1]).
|
-export([roots/0, fields/1, namespace/0, tags/0, desc/1]).
|
||||||
|
|
||||||
-export([translate/1]).
|
-export([translate/1]).
|
||||||
|
-export([translate/2]).
|
||||||
|
|
||||||
roots() ->
|
roots() ->
|
||||||
[s3].
|
[s3].
|
||||||
|
@ -36,7 +37,8 @@ fields(s3) ->
|
||||||
string(),
|
string(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("secret_access_key"),
|
desc => ?DESC("secret_access_key"),
|
||||||
required => false
|
required => false,
|
||||||
|
sensitive => true
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{bucket,
|
{bucket,
|
||||||
|
@ -142,7 +144,10 @@ desc(transport_options) ->
|
||||||
"Options for the HTTP transport layer used by the S3 client".
|
"Options for the HTTP transport layer used by the S3 client".
|
||||||
|
|
||||||
translate(Conf) ->
|
translate(Conf) ->
|
||||||
Options = #{atom_key => true},
|
translate(Conf, #{}).
|
||||||
|
|
||||||
|
translate(Conf, OptionsIn) ->
|
||||||
|
Options = maps:merge(#{atom_key => true}, OptionsIn),
|
||||||
#{s3 := TranslatedConf} = hocon_tconf:check_plain(
|
#{s3 := TranslatedConf} = hocon_tconf:check_plain(
|
||||||
emqx_s3_schema, #{<<"s3">> => Conf}, Options, [s3]
|
emqx_s3_schema, #{<<"s3">> => Conf}, Options, [s3]
|
||||||
),
|
),
|
||||||
|
|
|
@ -108,6 +108,25 @@ t_full_config(_Config) ->
|
||||||
})
|
})
|
||||||
).
|
).
|
||||||
|
|
||||||
|
t_sensitive_config_hidden(_Config) ->
|
||||||
|
?assertMatch(
|
||||||
|
#{
|
||||||
|
access_key_id := "access_key_id",
|
||||||
|
secret_access_key := <<"******">>
|
||||||
|
},
|
||||||
|
emqx_s3_schema:translate(
|
||||||
|
#{
|
||||||
|
<<"bucket">> => <<"bucket">>,
|
||||||
|
<<"host">> => <<"s3.us-east-1.endpoint.com">>,
|
||||||
|
<<"port">> => 443,
|
||||||
|
<<"access_key_id">> => <<"access_key_id">>,
|
||||||
|
<<"secret_access_key">> => <<"secret_access_key">>
|
||||||
|
},
|
||||||
|
% NOTE: this is what Config API handler is doing
|
||||||
|
#{obfuscate_sensitive_values => true}
|
||||||
|
)
|
||||||
|
).
|
||||||
|
|
||||||
t_invalid_limits(_Config) ->
|
t_invalid_limits(_Config) ->
|
||||||
?assertException(
|
?assertException(
|
||||||
throw,
|
throw,
|
||||||
|
|
Loading…
Reference in New Issue