Skip to content

Commit fef71a1

Browse files
version update
1 parent 1947b31 commit fef71a1

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecUpdateRefreshToken.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Function Invoke-ExecUpdateRefreshToken {
2020
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
2121
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
2222
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
23-
if ($env:ApplicationId -eq $Request.body.tenantId) {
23+
if ($env:TenantID -eq $Request.body.tenantId) {
2424
$Secret.RefreshToken = $Request.body.RefreshToken
2525
} else {
26-
Write-Host "$($env:Applicationid) does not match $($Request.body.tenantId)"
26+
Write-Host "$($env:TenantID) does not match $($Request.body.tenantId)"
2727
$name = $Request.body.tenantId -replace '-', '_'
2828
$secret | Add-Member -MemberType NoteProperty -Name $name -Value $Request.body.refreshtoken -Force
2929
}
@@ -38,13 +38,17 @@ Function Invoke-ExecUpdateRefreshToken {
3838
}
3939
$InstanceId = Start-UpdatePermissionsOrchestrator #start the CPV refresh immediately while wizard still runs.
4040

41-
41+
if ($request.body.tenantId -eq $env:TenantID) {
42+
$TenantName = 'your partner tenant'
43+
} else {
44+
$TenantName = $request.body.tenantId
45+
}
4246
$Results = @{
43-
'message' = "Successfully updated your stored authentication for $($request.body.tenantId)."
44-
'tenantId' = $Request.body.tenantId
47+
'message' = "Successfully updated the credentials for $($TenantName). You may continue to the next step, or add additional tenants if required."
48+
'severity' = 'success'
4549
}
4650
} catch {
47-
$Results = [pscustomobject]@{'Results' = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"; severity = 'failed' }
51+
$Results = [pscustomobject]@{'Results' = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"; severity = 'failed' }
4852
}
4953

5054
# Associate values to output bindings by calling 'Push-OutputBinding'.

Modules/CIPPCore/Public/Get-CIPPAuthentication.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ function Get-CIPPAuthentication {
2020
}
2121
Write-Host "Got secrets from dev storage. ApplicationID: $env:ApplicationID"
2222
#Get list of tenants that have 'directTenant' set to true
23-
$tenants = Get-Tenants | Where-Object -Property delegatedPrivilegeStatus -EQ 'directTenant'
23+
$tenants = Get-Tenants -IncludeErrors | Where-Object -Property delegatedPrivilegeStatus -EQ 'directTenant'
2424
if ($tenants) {
2525
Write-Host "Found $($tenants.Count) tenants with directTenant set to true"
2626
$tenants | ForEach-Object {
27-
$name = $_.customerId -replace '-', '_'
28-
if ($secret.$name) {
27+
$secretname = $_.customerId -replace '-', '_'
28+
if ($secret.$secretname) {
2929
$name = $_.customerId
30-
Set-Item -Path env:$name -Value $secret.$name -Force
30+
Write-Host "Setting $name to $($secret.$secretname)"
31+
32+
Set-Item -Path env:$name -Value $secret.$secretname -Force
3133
}
3234
}
3335
}
@@ -50,7 +52,7 @@ function Get-CIPPAuthentication {
5052

5153
$keyvaultname = ($env:WEBSITE_DEPLOYMENT_ID -split '-')[0]
5254
#Get list of tenants that have 'directTenant' set to true
53-
$tenants = Get-Tenants | Where-Object -Property delegatedPrivilegeStatus -EQ 'directTenant'
55+
$tenants = Get-Tenants -IncludeErrors | Where-Object -Property delegatedPrivilegeStatus -EQ 'directTenant'
5456
if ($tenants) {
5557
$tenants | ForEach-Object {
5658
$name = $_.tenantId -replace '-', '_'

Modules/CIPPCore/Public/GraphHelper/Get-AuthorisedRequest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Get-AuthorisedRequest {
1616
if ($Uri -like 'https://graph.microsoft.com/beta/contracts*' -or $Uri -like '*/customers/*' -or $Uri -eq 'https://graph.microsoft.com/v1.0/me/sendMail' -or $Uri -like '*/tenantRelationships/*' -or $Uri -like '*/security/partner/*') {
1717
return $true
1818
}
19-
$Tenant = Get-Tenants -TenantFilter $TenantID | Where-Object { $_.Excluded -eq $false }
19+
$Tenant = Get-Tenants -IncludeErrors -TenantFilter $TenantID | Where-Object { $_.Excluded -eq $false }
2020

2121
if ($Tenant) {
2222
return $true

Modules/CIPPCore/Public/GraphHelper/Get-GraphToken.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $AppSecret, $refreshT
66
if (!$scope) { $scope = 'https://graph.microsoft.com/.default' }
77
if (!$env:SetFromProfile) { $CIPPAuth = Get-CIPPAuthentication; Write-Host 'Could not get Refreshtoken from environment variable. Reloading token.' }
88
#If the $env:<$tenantid> is set, use that instead of the refreshtoken for all tenants.
9-
$ClientRefreshToken = Get-Item env:$tenantid -ErrorAction SilentlyContinue
10-
if ($ClientRefreshToken) {
11-
$refreshToken = $ClientRefreshToken
12-
} else {
13-
$refreshToken = $env:RefreshToken
9+
$refreshToken = $env:Refreshtoken
10+
$ClientType = Get-Tenants -IncludeErrors -TenantFilter $tenantid
11+
if ($clientType.delegatedPrivilegeStatus -eq 'directTenant') {
12+
$ClientRefreshToken = Get-Item -Path "env:\$($clientType.customerId)" -ErrorAction SilentlyContinue
13+
$refreshToken = $ClientRefreshToken.Value
1414
}
1515

1616
$AuthBody = @{

profile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ if (!$LastStartup -or $CurrentVersion -ne $LastStartup.Version) {
6262
Version = $CurrentVersion
6363
}
6464
}
65-
Update-AzDataTableEntity @Table -Entity $LastStartup -Force
65+
Update-AzDataTableEntity @Table -Entity $LastStartup -Force -ErrorAction SilentlyContinue
6666
try {
6767
Clear-CippDurables
6868
} catch {

0 commit comments

Comments
 (0)