Skip to content

Prepare ConfigureExchangeHybridApplication script to use 1P HCW app#2549

Open
lusassl-msft wants to merge 7 commits into
mainfrom
lusassl-3PGraphApi-03062026
Open

Prepare ConfigureExchangeHybridApplication script to use 1P HCW app#2549
lusassl-msft wants to merge 7 commits into
mainfrom
lusassl-3PGraphApi-03062026

Conversation

@lusassl-msft

Copy link
Copy Markdown
Contributor

Description:
With this PR, we change several things:

  1. We start using the Microsoft Exchange Hybrid Wizard first-party application to acquire the identity and access token
  2. We start supporting the Device Code Flow token workflow on Windows Server Core - this removes the dependency to a web browser
  3. The script enables the Setting Override that controls the Graph API MailTips workflow
  4. It fixes an issue in the Setting Override detection logic

Validation:
Lab / Test Team (validation pending)

Copilot AI review requested due to automatic review settings June 8, 2026 12:22
@lusassl-msft lusassl-msft requested review from a team and tweekerz as code owners June 8, 2026 12:22
@lusassl-msft lusassl-msft added Do not merge Do not merge yet as work is still in progress or waiting for other PR to be merged first Test Team Need to get the test involved and aware of this. labels Jun 8, 2026
@lusassl-msft lusassl-msft added documentation Improvements or additions to documentation Enhancement New feature or request labels Jun 8, 2026
@lusassl-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the hybrid-application onboarding/authentication flow across the repo, switching token acquisition to the first-party “Microsoft Exchange Hybrid Wizard” app and adding device-code authentication support for browser-less hosts (notably Windows Server Core). It also updates ConfigureExchangeHybridApplication to enable the Graph MailTips routing setting override and improves the Setting Override “Enabled=” detection when overrides contain multiple parameters.

Changes:

  • Updated Get-GraphAccessToken to use the HCW first-party client ID, default to .default openid profile, and add OAuth 2.0 device code flow support.
  • Removed Graph-call dependency for signed-in user/admin-consent eligibility checks by decoding access token claims (oid/wids) instead.
  • Added Server Core detection helper and integrated device-code selection into ConfigureExchangeHybridApplication and the CVE-2023-23397 script; updated docs and spelling dictionary.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Shared/Test-IsServerCoreOperatingSystem.ps1 Adds a helper to detect Windows Server Core to drive browser-less auth decisions.
Shared/ScriptUpdateFunctions/Invoke-WebRequestWithProxyDetection.ps1 Adds an opt-in mode to surface HTTP error responses (needed for device-code polling).
Shared/GraphApiFunctions/Update-ExchangeAzureApplication.ps1 Updates signed-in user lookup to use the new token-claims-based helper signature.
Shared/GraphApiFunctions/New-ExchangeAzureApplication.ps1 Updates signed-in user lookup to use the new token-claims-based helper signature.
Shared/GraphApiFunctions/Get-AzureSignedInUserInformation.ps1 Reworks signed-in user/admin-consent eligibility to read JWT claims instead of calling Graph.
Shared/AzureFunctions/Get-GraphAccessToken.ps1 Switches to HCW app + .default scopes, and adds device code flow support.
Security/src/CVE-2023-23397/CVE-2023-23397.ps1 Adds -UseDeviceCodeFlow and automatic Server Core device-code selection for Graph auth.
Hybrid/ConfigureExchangeHybridApplication/ConfigureExchangeHybridApplication.ps1 Adds -UseDeviceCodeFlow, auto Server Core device-code selection, fixes override detection, and enables MailTips routing override parameters.
docs/Security/CVE-2023-23397/index.md Documents the new UseDeviceCodeFlow switch.
docs/Hybrid/ConfigureExchangeHybridApplication.md Documents UseGraphApiOnly, RemoveApiPermissions, and UseDeviceCodeFlow.
.build/cspell-words.txt Adds new terms used by the device-code flow and token-claim logic.

Comment on lines +234 to +239
if (-not $connectionSuccessful) {
Write-Host "Timed out waiting for the device code sign-in to complete." -ForegroundColor Red
}

return
}
Comment on lines +186 to +190
if (($null -ne $redeemDeviceCodeResponse) -and
($redeemDeviceCodeResponse.StatusCode -eq 200)) {
$tokens = $redeemDeviceCodeResponse.Content | ConvertFrom-Json
$idTokenPayload = (Convert-JsonWebTokenToObject $tokens.id_token).Payload
$connectionSuccessful = $true
return
}

$idTokenPayload = (Convert-JsonWebTokenToObject $tokens.id_token).Payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do not merge Do not merge yet as work is still in progress or waiting for other PR to be merged first documentation Improvements or additions to documentation Enhancement New feature or request Test Team Need to get the test involved and aware of this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants