Skip to content

Commit cca94f1

Browse files
feat: enable sensitive fields encryption by default (#11076)
1 parent 538b948 commit cca94f1

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

apisix/plugin.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ local function enable_gde()
907907
if enable_data_encryption == nil then
908908
enable_data_encryption =
909909
core.table.try_read_attr(local_conf, "apisix", "data_encryption",
910-
"enable_encrypt_fields")
910+
"enable_encrypt_fields") and (core.config.type == "etcd")
911911
_M.enable_data_encryption = enable_data_encryption
912912
end
913913

conf/config-default.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ apisix:
118118
disable_sync_configuration_during_start: false # Safe exit. TO BE REMOVED.
119119

120120
data_encryption: # Data encryption settings.
121-
enable_encrypt_fields: false # Whether enable encrypt fields specified in `encrypt_fields` in plugin schema.
121+
enable_encrypt_fields: true # Whether enable encrypt fields specified in `encrypt_fields` in plugin schema.
122122
keyring: # This field is used to encrypt the private key of SSL and the `encrypt_fields`
123123
# in plugin schema.
124124
- qeddd145sfvddff3 # Set the encryption key for AES-128-CBC. It should be a hexadecimal string

t/admin/consumers.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ passed
8787
"desc": "new consumer",
8888
"plugins": {
8989
"key-auth": {
90-
"key": "auth-one"
90+
"key": "4y+JvURBE6ZwRbbgaryrhg=="
9191
}
9292
}
9393
},

t/node/chash-hashon.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ __DATA__
5555
"username": "jack",
5656
"plugins": {
5757
"key-auth": {
58-
"key": "auth-jack"
58+
"key": "re62sf0vRJqOBjvJJ6RUcA=="
5959
}
6060
}
6161
}
@@ -83,7 +83,7 @@ __DATA__
8383
"username": "tom",
8484
"plugins": {
8585
"key-auth": {
86-
"key": "auth-tom"
86+
"key": "RAL/niDfEUpx+ynsoqWDuA=="
8787
}
8888
}
8989
}

t/plugin/error-log-logger-clickhouse.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ done
9898
--- error_log
9999
this is a warning message for test2
100100
clickhouse body: INSERT INTO t FORMAT JSONEachRow
101-
clickhouse headers: x-clickhouse-key:a
101+
clickhouse headers: x-clickhouse-key:dpwomMlEsHH2L7wSUi6YiQ==
102102
clickhouse headers: x-clickhouse-user:default
103103
clickhouse headers: x-clickhouse-database:default
104104
--- wait: 3
@@ -133,7 +133,7 @@ clickhouse headers: x-clickhouse-database:default
133133
--- error_log
134134
this is a warning message for test3
135135
clickhouse body: INSERT INTO t FORMAT JSONEachRow
136-
clickhouse headers: x-clickhouse-key:a
136+
clickhouse headers: x-clickhouse-key:dpwomMlEsHH2L7wSUi6YiQ==
137137
clickhouse headers: x-clickhouse-user:default
138138
clickhouse headers: x-clickhouse-database:default
139139
--- wait: 5

t/plugin/key-auth.t

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ use t::APISIX 'no_plan';
2323
repeat_each(2);
2424
no_long_string();
2525
no_root_location();
26+
27+
add_block_preprocessor(sub {
28+
my ($block) = @_;
29+
30+
my $user_yaml_config = <<_EOC_;
31+
apisix:
32+
data_encryption:
33+
enable_encrypt_fields: false
34+
_EOC_
35+
$block->set_value("yaml_config", $user_yaml_config);
36+
});
37+
38+
2639
run_tests;
2740

2841
__DATA__

0 commit comments

Comments
 (0)