Skip to content

Commit 0a8b617

Browse files
fix(auth): skip placeholder TenantID in GUID resolution
Fresh deployments hold 'tenantId' as a placeholder until the setup wizard writes real secrets. Skip the OpenID metadata lookup for placeholder values to avoid unnecessary errors on initial deployment. Synced from CyberDrain/CIPP@acea292
1 parent 9a32965 commit 0a8b617

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Modules/CIPPCore/Public/Get-CIPPAuthentication.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ function Get-CIPPAuthentication {
3030
# TenantID must be the tenant GUID: a domain name (contoso.onmicrosoft.com)
3131
# works for token requests but breaks API integrations that compare or store
3232
# tenant ids. Resolve a domain to its GUID via the unauthenticated OpenID
33-
# metadata endpoint.
33+
# metadata endpoint. Skip the deployment template's placeholder value —
34+
# fresh deployments hold 'tenantId' until the setup wizard writes real
35+
# secrets (same placeholder set as Initialize-CIPPAuth).
3436
$GuidPattern = '^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$'
35-
if ($env:TenantID -and $env:TenantID -notmatch $GuidPattern) {
37+
$PlaceholderPattern = '^(LongApplicationId|AppSecret|RefreshToken|tenantId)$'
38+
if ($env:TenantID -and $env:TenantID -notmatch $GuidPattern -and $env:TenantID -notmatch $PlaceholderPattern) {
3639
$StoredTenantID = $env:TenantID
3740
try {
3841
$OpenIdConfig = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$StoredTenantID/v2.0/.well-known/openid-configuration" -ErrorAction Stop

0 commit comments

Comments
 (0)