-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix SendAsync from impersonated context with default credentials #58922
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsAs @geoffkizer suggested, this brown 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. 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 inpersonification 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 With that, I added new test to verify that HttpClient will open new connection for the inpersonioficated context. fixes #58033
|
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Net.Http/tests/FunctionalTests/NtAuthTests.Windows.cs
Outdated
Show resolved
Hide resolved
...aries/System.Security.Principal.Windows/tests/WindowsIdentityImpersonatedTests.netcoreapp.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionSettings.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small issues above, generally looks good.
Test failures seems unrelated. I did not see any failure related to authentication. |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please find and replace Impersonificated => Impersonated
Other than that, LGTM
test failures looks unrelated. Mostly infrastructure & #58927. |
Does this need 6.0 port.. |
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1237858774 |
As @geoffkizer suggested, this fails because the connection setting is updated only in constructor. Even if options are passed to
HttpHandler
constructor, we actually createHttpConnectionSettings
first and then we updated it.I was originally thinking about updating relevant setters in
HttpHandler
but I end up updating theCloneAndNormalize
and that seems sufficient. That has benefit that all the logic is still encapsulated inHttpConnectionSettings
.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 relianceHttpListener
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
toTestUtilities
. That essentially creates ad hoc account and use that for testing. That seems to require some level of privilege. The existing tests inSystem.Security
did not have any guard and they seems to run fine in CI. We can possibly updateCanRunImpersonatedTests
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.
Fixes #58033