[Core] Persist cross domain redirect flag#45518
Open
pvaneck wants to merge 1 commit intoAzure:mainfrom
Open
Conversation
45d09eb to
5d6302d
Compare
Contributor
There was a problem hiding this comment.
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_changeonrequest.context(notrequest.context.options) in sync/async redirect policies. - Update
SensitiveHeaderCleanupPolicyto read the flag fromrequest.contextso 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. |
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>
7091c82 to
487ed32
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Set the
insecure_domain_changeflag onrequest.contextinstead ofrequest.context.optionsin order to persist it for all request attempts.