Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/6.0] Fix SendAsync from impersonated context with default credentials #59155

Merged
merged 5 commits into from
Sep 15, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 15, 2021

Backport of #58922 to release/6.0

Fixes #58033

As @geoffkizer suggested, this fails because the connection setting is updated only in constructor. Even if options are passed to HttpHandler constructor, we actually create HttpConnectionSettings first and then we updated it.
I was originally thinking about updating relevant setters in HttpHandler but I end up updating the CloneAndNormalize and that seems sufficient. That has benefit that all the logic is still encapsulated in HttpConnectionSettings.
This is pretty trivial two line change.

Now, the trouble is testing. Some existing NTLM tests use HttpListener and that is problematic because of lack of fine control and general reliance. And we do not have any impersonation tests for HTTP.

To solve the first issue, I used NTLM code from Common and I added (duplicate?) NTLM/Negotiate test using standard Loopback pattern. If that proves to be stable and working we can possibly remove reliance HttpListener and clean up rest of the tests. (and get some more coverage for code Kestrel use via reflection (or make that finally public)).

To solve the second problem, I moved existing WindowsIdentityFixture to TestUtilities. That essentially creates ad hoc account and use that for testing. That seems to require some level of privilege. The existing tests in System.Security did not have any guard and they seems to run fine in CI. We can possibly update CanRunImpersonatedTests if this becomes nuisance. Certainly running tests from elevated shell seems to work fine but I don't know if that is really needed.

With that, I added new test to verify that HttpClient will open new connection for the impersonated context.
And it also verifies that the authenticated identity is different.

/cc @danmoseley @wfurt

Customer Impact

Testing

Risk

@ghost
Copy link

ghost commented Sep 15, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #58922 to release/6.0

/cc @danmoseley @wfurt

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Net

Milestone: -

@danmoseley danmoseley added the Servicing-approved Approved for servicing release label Sep 15, 2021
@danmoseley
Copy link
Member

Approved per discussion offline. No need to fill out template.

@karelz karelz added this to the 6.0.0 milestone Sep 15, 2021
Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

LGTM

@Anipik Anipik merged commit b5e15dc into release/6.0 Sep 15, 2021
@Anipik Anipik deleted the backport/pr-58922-to-release/6.0 branch September 15, 2021 17:45
@karelz karelz changed the title [release/6.0] fix SendAsync from impersonificated context with default credentials [release/6.0] Fix SendAsync from impersonated context with default credentials Sep 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants