Skip to content

Commit

Permalink
MSAL - Authority is added for national clouds (#18222) (#18256)
Browse files Browse the repository at this point in the history
* - authority is fixed for national clouds
  • Loading branch information
ozanMSFT committed May 9, 2023
1 parent 26acee3 commit b403dcc
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 1,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 1,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 3,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 3,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 4,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 4,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 5,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 5,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"azureps"
Expand Down
8 changes: 4 additions & 4 deletions Tasks/Common/VstsAzureRestHelpers_/VstsAzureRestHelpers_.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -370,28 +370,28 @@ function Build-MSALInstance {
# load the MSAL library
Add-Type -Path "$PSScriptRoot\msal\Microsoft.Identity.Client.dll"

$clientBuilder = [Microsoft.Identity.Client.ConfidentialClientApplicationBuilder]::Create($clientId)
$clientBuilder = [Microsoft.Identity.Client.ConfidentialClientApplicationBuilder]::Create($clientId).WithAuthority($envAuthUrl, $tenantId)

if ($Endpoint.Auth.Parameters.AuthenticationType -eq 'SPNCertificate') {
Write-Verbose "MSAL - ServicePrincipal - certificate is used.";

$pemFileContent = $endpoint.Auth.Parameters.ServicePrincipalCertificate
$pfxFilePath, $pfxFilePassword = ConvertTo-Pfx -pemFileContent $pemFileContent
$clientCertificate = Get-PfxCertificate -pfxFilePath $pfxFilePath -pfxFilePassword $pfxFilePassword
$msalClientInstance = $clientBuilder.WithTenantId($tenantId).WithCertificate($clientCertificate).Build()
$msalClientInstance = $clientBuilder.WithCertificate($clientCertificate).Build()
}
elseif ($endpoint.Auth.Scheme -eq $wifConnection) {
Write-Verbose "MSAL - WorkloadIdentityFederation is used";

$oidc_token = Get-VstsFederatedToken -serviceConnectionId $connectedServiceNameARM -vstsAccessToken $vstsAccessToken

$msalClientInstance = $clientBuilder.WithTenantId($tenantId).WithClientAssertion($oidc_token).Build()
$msalClientInstance = $clientBuilder.WithClientAssertion($oidc_token).Build()
}
else {
Write-Verbose "MSAL - ServicePrincipal - clientSecret is used.";

$clientSecret = $endpoint.Auth.Parameters.ServicePrincipalKey
$msalClientInstance = $clientBuilder.WithTenantId($tenantId).WithClientSecret($clientSecret).Build()
$msalClientInstance = $clientBuilder.WithClientSecret($clientSecret).Build()
}

return $msalClientInstance
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SqlAzureDacpacDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"sqlpackage"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SqlAzureDacpacDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 221,
"Patch": 102
"Patch": 103
},
"demands": [
"sqlpackage"
Expand Down

0 comments on commit b403dcc

Please sign in to comment.