Skip to content

Enhance ConfigureExchangeHybridApplication.ps1 based on customer and internal feedback - #2387

Merged
dpaulson45 merged 3 commits into
mainfrom
lusassl-12082025-1
Aug 18, 2025
Merged

Enhance ConfigureExchangeHybridApplication.ps1 based on customer and internal feedback#2387
dpaulson45 merged 3 commits into
mainfrom
lusassl-12082025-1

Conversation

@lusassl-msft

@lusassl-msft lusassl-msft commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

Description:

  • ConfigureAuthServer logic simplified
    • We now copy the DomainName values from the corresponding MicrosoftACS Auth Server if there is one
    • We now compare the AcceptedDomain on the on-premises side with the domains returned via Graph API call if no corresponding MicrosoftACS object was found and we use the matching domains
  • Improvements to Get-GraphAccessToken to make it more robust
  • Improvements to Remove-CertificateFromAzureServicePrincipal to return more context about the operation that was performed

Validation:
Lab

@lusassl-msft
lusassl-msft requested review from a team and tweekerz as code owners August 14, 2025 15:54
@lusassl-msft lusassl-msft added the Do not merge Do not merge yet as work is still in progress or waiting for other PR to be merged first label Aug 14, 2025
@lusassl-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

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

@lusassl-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

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

@lusassl-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

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

Comment thread Hybrid/ConfigureExchangeHybridApplication/ConfigureExchangeHybridApplication.ps1 Outdated
Comment thread Hybrid/ConfigureExchangeHybridApplication/ConfigureExchangeHybridApplication.ps1 Outdated
Comment thread Hybrid/ConfigureExchangeHybridApplication/ConfigureExchangeHybridApplication.ps1 Outdated
Comment thread Hybrid/ConfigureExchangeHybridApplication/ConfigureExchangeHybridApplication.ps1 Outdated
Comment thread Shared/AzureFunctions/Get-GraphAccessToken.ps1
Comment on lines +121 to +139
if (-not $returnedState) {
Write-Host "No state value was returned" -ForegroundColor Red

return
}

Write-Verbose "Script state: '$state' - Returned state: '$returnedState'"

if ($returnedState -cne $state) {
Write-Host "State mismatch detected! Expected '$state', got '$returnedState'" -ForegroundColor Red

return
}

$code = $queryString["code"]

if (-not $code) {
Write-Host "Authorization code is missing in callback" -ForegroundColor Red

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we ever expect something like this to happen, if so should we provide what to do if this does happen?

@lusassl-msft lusassl-msft Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The state parameter binds the authorization response to this specific client request and provides CSRF protection. The client generates a random, unguessable value, stores it locally, sends it in the /authorize request, and verifies it on callback. If the returned state doesn’t match the stored value, the response is ignored - preventing stray redirects (e.g., from another tab/app/tenant) and attacker attempts to have the client redeem unsolicited results.

So, yes - it's possible that we end up here but it's unexpected and this code should prevent the client from continue processing => we don't redeem the returned code for an access token.

This is a very, very rare situation.

Comment thread Shared/GraphApiFunctions/Remove-CertificateFromAzureServicePrincipal.ps1 Outdated
@dpaulson45

Copy link
Copy Markdown
Member

@lusassl-msft please update the docs to state if you run into issues to review the debug log and its location to have a better understanding of the issue.

@lusassl-msft lusassl-msft removed the Do not merge Do not merge yet as work is still in progress or waiting for other PR to be merged first label Aug 18, 2025
@lusassl-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

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

@dpaulson45
dpaulson45 merged commit 6f8c415 into main Aug 18, 2025
4 checks passed
@dpaulson45
dpaulson45 deleted the lusassl-12082025-1 branch August 18, 2025 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants