Skip to content

[Core] Persist cross domain redirect flag#45518

Merged
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:core-redirect-flag
Mar 9, 2026
Merged

[Core] Persist cross domain redirect flag#45518
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:core-redirect-flag

Conversation

@pvaneck
Copy link
Copy Markdown
Member

@pvaneck pvaneck commented Mar 4, 2026

Set the insecure_domain_change flag on request.context instead of request.context.options in order to persist it for all request attempts.

@pvaneck pvaneck force-pushed the core-redirect-flag branch from 45d09eb to 5d6302d Compare March 4, 2026 21:15
@pvaneck pvaneck marked this pull request as ready for review March 4, 2026 22:28
Copilot AI review requested due to automatic review settings March 4, 2026 22:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 azure-core pipeline redirect handling so the insecure_domain_change marker persists across retry attempts, ensuring SensitiveHeaderCleanupPolicy continues stripping sensitive auth headers after a cross-domain redirect.

Changes:

  • Store insecure_domain_change on request.context (not request.context.options) in sync/async redirect policies.
  • Update SensitiveHeaderCleanupPolicy to read the flag from request.context so it applies across retries.
  • Add sync/async regression tests covering cross-domain redirect + retry behavior and document the fix in the changelog.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/core/azure-core/azure/core/pipeline/policies/_sensitive_header_cleanup_policy.py Reads insecure_domain_change from request.context so header cleanup can apply across multiple attempts.
sdk/core/azure-core/azure/core/pipeline/policies/_redirect.py Sets insecure_domain_change on request.context when redirected across domains (sync).
sdk/core/azure-core/azure/core/pipeline/policies/_redirect_async.py Sets insecure_domain_change on request.context when redirected across domains (async).
sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py Removes clearing of the redirect flag during challenge resend (sync).
sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py Removes clearing of the redirect flag during challenge resend (async).
sdk/core/azure-core/tests/test_authentication.py Adds tests validating auth header stripping after cross-domain redirect, including a retry scenario.
sdk/core/azure-core/tests/async_tests/test_authentication_async.py Adds async equivalents of the new redirect/challenge/retry stripping tests.
sdk/core/azure-core/CHANGELOG.md Adds a bug fix entry describing the retry + cross-domain redirect header cleanup behavior.

Comment thread sdk/core/azure-core/tests/test_authentication.py Outdated
Set the `insecure_domain_change` flag on `request.context` instead of `request.context.options`
in order to persist it for all request attempts.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>

Remove print

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the core-redirect-flag branch from 7091c82 to 487ed32 Compare March 4, 2026 23:26
@pvaneck
Copy link
Copy Markdown
Member Author

pvaneck commented Mar 9, 2026

/check-enforcer override

@pvaneck pvaneck merged commit 2117dfb into Azure:main Mar 9, 2026
51 of 55 checks passed
@pvaneck pvaneck deleted the core-redirect-flag branch March 9, 2026 22:50
aprilk-ms pushed a commit that referenced this pull request Mar 11, 2026
Set the `insecure_domain_change` flag on `request.context` instead of `request.context.options`
in order to persist it for all request attempts.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
singankit pushed a commit that referenced this pull request Mar 16, 2026
Set the `insecure_domain_change` flag on `request.context` instead of `request.context.options`
in order to persist it for all request attempts.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
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.

4 participants