GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Limit credentials to the origin host by jshigetomi · Pull Request #28399 · PowerShell/PowerShell Conversation
|
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Reused web sessions retain default credentials after UseDefaultCredentials is disabled, while credential-cache handling also causes redirect-authentication and connection-reuse regressions.
This PR hardens credential handling in PowerShell’s web cmdlets by scoping credentials to the request origin unless redirect authorization preservation is enabled.
Changes:
| File | Description |
|---|---|
test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 |
Expands credential-scoping tests for both web cmdlets. |
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs |
Adds origin-scoped credential cache creation. |
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs |
Routes explicit and default credentials through the new session helper. |
Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| else if (UseDefaultCredentials) | ||
| { | ||
| WebSession.UseDefaultCredentials = true; | ||
| WebSession.SetCredential(CredentialCache.DefaultNetworkCredentials, CheckProtocol(Uri), PreserveAuthorizationOnRedirect); |
| // Get the relevant NetworkCredential | ||
| NetworkCredential netCred = Credential.GetNetworkCredential(); | ||
| WebSession.Credentials = netCred; | ||
| WebSession.SetCredential(Credential.GetNetworkCredential(), CheckProtocol(Uri), PreserveAuthorizationOnRedirect); |
| cache.Add(origin, scheme, cred); | ||
| } | ||
|
|
||
| Credentials = cache; |
|
Patrick Meinecke (@SeeminglyScience) can you please take a look at the Copilot comments? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.