Skip to content

Commit 155d56f

Browse files
danieljurekazure-sdk
authored andcommitted
Clear secrets if FederatedAuth is set
1 parent 51ba0da commit 155d56f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ if ($ServicePrincipalAuth) {
120120
$UserAuth = $false
121121
}
122122

123+
if ($FederatedAuth) {
124+
# Clear secrets if FederatedAuth is set. This prevents secrets from being
125+
# passed to pre- and post-scripts.
126+
$PSBoundParameters['TestApplicationSecret'] = $TestApplicationSecret = ''
127+
$PSBoundParameters['ProvisionerApplicationSecret'] = $ProvisionerApplicationSecret = ''
128+
}
129+
123130
# By default stop for any error.
124131
if (!$PSBoundParameters.ContainsKey('ErrorAction')) {
125132
$ErrorActionPreference = 'Stop'
@@ -282,8 +289,6 @@ function BuildDeploymentOutputs([string]$serviceName, [object]$azContext, [objec
282289
$serviceDirectoryPrefix = BuildServiceDirectoryPrefix $serviceName
283290
# Add default values
284291
$deploymentOutputs = [Ordered]@{
285-
"${serviceDirectoryPrefix}CLIENT_ID" = $TestApplicationId;
286-
"${serviceDirectoryPrefix}TENANT_ID" = $azContext.Tenant.Id;
287292
"${serviceDirectoryPrefix}SUBSCRIPTION_ID" = $azContext.Subscription.Id;
288293
"${serviceDirectoryPrefix}RESOURCE_GROUP" = $resourceGroup.ResourceGroupName;
289294
"${serviceDirectoryPrefix}LOCATION" = $resourceGroup.Location;
@@ -295,7 +300,9 @@ function BuildDeploymentOutputs([string]$serviceName, [object]$azContext, [objec
295300
}
296301

297302
if (!$FederatedAuth) {
303+
$deploymentOutputs["${serviceDirectoryPrefix}CLIENT_ID"] = $TestApplicationId;
298304
$deploymentOutputs["${serviceDirectoryPrefix}CLIENT_SECRET"] = $TestApplicationSecret;
305+
$deploymentOutputs["${serviceDirectoryPrefix}TENANT_ID"] = $azContext.Tenant.Id;
299306
}
300307

301308
MergeHashes $environmentVariables $(Get-Variable deploymentOutputs)

0 commit comments

Comments
 (0)