-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1985 from robgolebiowski/5.7_keyring_vault_removi…
…ng_keys_from_vault PS-256: keys created by keyring_vault MTR tests are not removed from
- Loading branch information
Showing
19 changed files
with
201 additions
and
94 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
mysql-test/std_data/keyring_vault_confs/keyring_vault_mtr_invalid_token_template.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
vault_url = https://vault.public-ci.percona.com:8200 | ||
secret_mount_point = secret | ||
secret_mount_point = SECRET_MOUNT_POINT_TAG | ||
token = 58a90c08-8001-fd5f-6192-7498a48eaf20 | ||
vault_ca = MYSQL_TEST_DIR/std_data/keyring_vault_confs/vault_ca.crt |
2 changes: 1 addition & 1 deletion
2
mysql-test/std_data/keyring_vault_confs/keyring_vault_mtr_template1.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
vault_url = https://vault.public-ci.percona.com:8200 | ||
secret_mount_point = secret | ||
secret_mount_point = SECRET_MOUNT_POINT_TAG | ||
token = 58a90c08-8001-fd5f-6192-7498a48eaf2a | ||
vault_ca = MYSQL_TEST_DIR/std_data/keyring_vault_confs/vault_ca.crt |
2 changes: 1 addition & 1 deletion
2
mysql-test/std_data/keyring_vault_confs/keyring_vault_mtr_template2.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
vault_url = https://vault.public-ci.percona.com:8400 | ||
secret_mount_point = secret | ||
secret_mount_point = SECRET_MOUNT_POINT_TAG | ||
token = 25cc5351-f5a7-a2c0-335b-065d6424f1b3 | ||
vault_ca = MYSQL_TEST_DIR/std_data/keyring_vault_confs/vault_ca.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Creates or deletes secret mount point specified in keyring_vault configuration file | ||
# Mount point is : | ||
# - created when MOUNT_POINT_SERVICE_OP is set to CREATE | ||
# - deleted when MOUNT_POINT_SERVICE_OP is set to DELETE | ||
|
||
# The sourcing test needs to set $KEYRING_CONF_FILE variable to | ||
# the location of keyring_vault configuration file and | ||
# MOUNT_POINT_SERVICE_OP variable to CREATE or DELETE | ||
let KEYRING_CONF_FILE=$KEYRING_CONF_FILE; | ||
let SERVER_UUID= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1); | ||
let MOUNT_POINT_SERVICE_OP=$MOUNT_POINT_SERVICE_OP; | ||
|
||
--perl | ||
use strict; | ||
use MIME::Base64 qw( decode_base64 ); | ||
my $keyring_conf_file= $ENV{'KEYRING_CONF_FILE'} or die("KEYRING_CONF_FILE not set\n"); | ||
my $server_uuid= $ENV{'SERVER_UUID'} or die("SERVER_UUID not set\n"); | ||
my $mount_point_service_op=$ENV{'MOUNT_POINT_SERVICE_OP'}; | ||
my $token; | ||
my $vault_url; | ||
my $secret_mount_point; | ||
my $vault_ca; | ||
my $CONF_FILE; | ||
open(CONF_FILE, "$keyring_conf_file") or die("Could not open configuration file.\n"); | ||
while (my $row = <CONF_FILE>) | ||
{ | ||
if ($row =~ m/token[ ]*=[ ]*(.*)/) | ||
{ | ||
$token=$1; | ||
} | ||
elsif ($row =~ m/vault_url[ ]*=[ ]*(.*)/) | ||
{ | ||
$vault_url=$1; | ||
} | ||
elsif ($row =~ m/secret_mount_point[ ]*= [ ]*(.*)/) | ||
{ | ||
$secret_mount_point=$1; | ||
} | ||
elsif ($row =~ m/vault_ca[ ]*= [ ]*(.*)/) | ||
{ | ||
$vault_ca=$1; | ||
} | ||
} | ||
close(CONF_FILE); | ||
if ($token eq "" || $vault_url eq "" || $secret_mount_point eq "") | ||
{ | ||
die("Could not read vault credentials from configuration file.\n"); | ||
} | ||
|
||
my $vault_ca_cert_opt= ""; | ||
if ($vault_ca) | ||
{ | ||
$vault_ca_cert_opt= "--cacert $vault_ca"; | ||
} | ||
|
||
if ($mount_point_service_op eq 'CREATE') | ||
{ | ||
system(qq#curl -H "X-Vault-Token: $token" $vault_ca_cert_opt --data '{"type":"generic"}' --request POST $vault_url/v1/sys/mounts/$secret_mount_point#); | ||
} | ||
elsif ($mount_point_service_op eq 'DELETE') | ||
{ | ||
system(qq#curl -H "X-Vault-Token: $token" $vault_ca_cert_opt -X DELETE $vault_url/v1/sys/mounts/$secret_mount_point#); | ||
} | ||
else | ||
{ | ||
die("Mount point should be either created or deleted. The resulting operation is no-op"); | ||
} | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
--source include/have_keyring_vault_plugin.inc | ||
--source generate_default_conf_files.inc | ||
|
||
# Create mount points | ||
--let MOUNT_POINT_SERVICE_OP=CREATE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source mount_point_service.inc | ||
|
||
--let $keyring_restart_param=restart:--early-plugin-load="keyring_vault=$KEYRING_VAULT_PLUGIN" --loose-keyring_vault_config=$KEYRING_CONF_FILE_1 $KEYRING_VAULT_PLUGIN_OPT | ||
--source include/table_encrypt_1.inc | ||
|
||
# Delete mount points | ||
--let MOUNT_POINT_SERVICE_OP=DELETE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source vault_cleanup.inc | ||
--source mount_point_service.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
--source include/have_keyring_vault_plugin.inc | ||
--source generate_default_conf_files.inc | ||
|
||
# Create mount points | ||
--let MOUNT_POINT_SERVICE_OP=CREATE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source mount_point_service.inc | ||
|
||
--let $keyring_plugin_name=keyring_vault | ||
--let $keyring_restart_param=restart: --early-plugin-load="keyring_vault=$KEYRING_VAULT_PLUGIN" --loose-keyring_vault_config=$KEYRING_CONF_FILE_1 $KEYRING_VAULT_PLUGIN_OPT | ||
--source include/table_encrypt_3.inc | ||
|
||
# Delete mount points | ||
--let MOUNT_POINT_SERVICE_OP=DELETE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source vault_cleanup.inc | ||
--source mount_point_service.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
--source include/have_keyring_vault_plugin.inc | ||
--source generate_default_conf_files.inc | ||
|
||
# Create mount points | ||
--let MOUNT_POINT_SERVICE_OP=CREATE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_2 | ||
--source mount_point_service.inc | ||
|
||
--let $keyring_restart_param=restart:--early-plugin-load="keyring_vault=$KEYRING_VAULT_PLUGIN" --loose-keyring_vault_config=$KEYRING_CONF_FILE_2 $KEYRING_VAULT_PLUGIN_OPT | ||
--source include/table_encrypt_4.inc | ||
|
||
# Delete mount points | ||
--let MOUNT_POINT_SERVICE_OP=DELETE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_2 | ||
--source vault_cleanup.inc | ||
--source mount_point_service.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
--source include/have_keyring_vault_plugin.inc | ||
--source generate_default_conf_files.inc | ||
|
||
# Create mount points | ||
--let MOUNT_POINT_SERVICE_OP=CREATE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source mount_point_service.inc | ||
|
||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--let $keyring_restart_param=restart: --early-plugin-load="keyring_vault=$KEYRING_VAULT_PLUGIN" --loose-keyring_vault_config=$KEYRING_CONF_FILE $KEYRING_VAULT_PLUGIN_OPT | ||
--source include/table_encrypt_debug.inc | ||
--source vault_cleanup.inc | ||
|
||
# Delete mount points | ||
--let MOUNT_POINT_SERVICE_OP=DELETE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source mount_point_service.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
--source include/have_keyring_vault_plugin.inc | ||
--source generate_default_conf_files.inc | ||
|
||
# Create mount points | ||
--let MOUNT_POINT_SERVICE_OP=CREATE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source mount_point_service.inc | ||
|
||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--let $keyring_restart_param=restart: --early-plugin-load="keyring_vault=$KEYRING_VAULT_PLUGIN" --loose-keyring_vault_config=$KEYRING_CONF_FILE $KEYRING_VAULT_PLUGIN_OPT | ||
--source include/table_encrypt_kill.inc | ||
--source vault_cleanup.inc | ||
|
||
# Delete mount points | ||
--let MOUNT_POINT_SERVICE_OP=DELETE | ||
--let $KEYRING_CONF_FILE=$KEYRING_CONF_FILE_1 | ||
--source mount_point_service.inc |
Oops, something went wrong.