Added AKV configuration to setup files

This commit is contained in:
David Puglielli 2018-05-07 14:16:40 -07:00
parent 2fe0b5a2bc
commit f49da62e5b
4 changed files with 30 additions and 8 deletions

View file

@ -92,6 +92,13 @@ function getDSN($sqlsrvserver, $database, $keywords = '', $disableCE = false)
if ($keystore != "none" && !$disableCE) {
$dsn .= "ColumnEncryption=Enabled;";
}
if ($keystore == "akv" && !$disableCE) {
if ($keyStoreAuthentication == "KeyVaultPassword") {
$dsn .= "KeyStoreAuthentication=$keyStoreAuthentication;KeyStorePrincipalId=$principalName;KeyStoreSecret=$AKVPassword;";
} else if ($keyStoreAuthentication == "KeyVaultClientSecret") {
$dsn .= "KeyStoreAuthentication=$keyStoreAuthentication;KeyStorePrincipalId=$clientID;KeyStoreSecret=$AKVSecret;";
}
}
if ($keystore == "ksp" && !$disableCE) {
$ksp_path = getKSPPath();
$ksp_name = KSP_NAME;

View file

@ -44,9 +44,11 @@ $traceEnabled = false;
$keystore = "none"; // key store provider, acceptable values are none, win, ksp, akv
$dataEncrypted = false; // whether data is to be encrypted
$principalName = 'name';
$clientID = 'clientid';
$AKVPassword = 'password';
$AKVSecret = 'secret';
// for Azure Key Vault
$keyStoreAuthentication = 'KeyVaultPassword'; // can be KeyVaultPassword or KeyVaultClientSecret
$principalName = 'name'; // for use with KeyVaultPassword
$AKVPassword = 'password'; // for use with KeyVaultPassword
$clientID = 'clientid'; // for use with KeyVaultClientSecret
$AKVSecret = 'secret'; // for use with KeyVaultClientSecret
?>

View file

@ -359,6 +359,17 @@ function connect($options = array(), $disableCE = false)
if (isColEncrypted()) {
$connectionOptions = array_merge($connectionOptions, array("ColumnEncryption" => "Enabled"));
}
if ($keystore == 'akv') {
$akv_options = array("KeyStoreAuthentication"=>$keyStoreAuthentication);
if ($keyStoreAuthentication == 'KeyVaultPassword') {
$akv_options["KeyStorePrincipalId"] = $principalName;
$akv_options["KeyStoreSecret"] = $AKVPassword;
} else if ($keyStoreAuthentication == "KeyVaultClientSecret") {
$akv_options["KeyStorePrincipalId"] = $clientID;
$akv_options["KeyStoreSecret"] = $AKVSecret;
}
$connectionOptions = array_merge($connectionOptions, $akv_options);
}
}
$conn = sqlsrv_connect($server, $connectionOptions);
if ($conn === false) {

View file

@ -44,9 +44,11 @@ if (isset($_ENV['MSSQL_SERVER']) || isset($_ENV['MSSQL_USER']) || isset($_ENV['M
$keystore = "none"; // key store provider, acceptable values are none, win, ksp, akv
$dataEncrypted = false; // whether data is to be encrypted
$principalName = 'name';
$clientID = 'clientid';
$AKVPassword = 'password';
$AKVSecret = 'secret';
// for Azure Key Vault
$keyStoreAuthentication = 'KeyVaultPassword'; // can be KeyVaultPassword or KeyVaultClientSecret
$principalName = 'name'; // for use with KeyVaultPassword
$AKVPassword = 'password'; // for use with KeyVaultPassword
$clientID = 'clientid'; // for use with KeyVaultClientSecret
$AKVSecret = 'secret'; // for use with KeyVaultClientSecret
?>