-
Notifications
You must be signed in to change notification settings - Fork 317
Expose SSPI context provider as public #2494
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
base: main
Are you sure you want to change the base?
Conversation
e16f2c8
to
cfcf164
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2494 +/- ##
===========================================
- Coverage 69.90% 59.06% -10.84%
===========================================
Files 276 270 -6
Lines 62414 62098 -316
===========================================
- Hits 43629 36677 -6952
- Misses 18785 25421 +6636
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
Outdated
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.
Overall, really like the goal and implementation. Most of my comments are style related, since I'm sure my colleagues have tackled the bigger questions.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSSPIContextProvider.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs
Outdated
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.
Made an initial pass, and came up with some questions/comments.
src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSSPIContextProvider.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs
Outdated
Show resolved
Hide resolved
380e896
to
2039bd9
Compare
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.
Factory vs instance in the netfx code, and a few questions about docs.
src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
5bb128f
to
8937cb7
Compare
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.
Latest package still works for our use-case
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
@paulmedynski @mdaigle the two failures look to be test failures with sql server setup. otherwise it's ready again |
@mdaigle @paulmedynski any updates on timing here? Are we still waiting for a security review? |
@twsouthwick yes, we still need to set up a security review. We had originally planned on doing that for the 6.1 release but opted to avoid security sensitive changes. I'm hoping I'll have a chance soon to update out threat model diagrams for this feature and then schedule a feature specific review. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiContextProvider.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.
How hard would it be to implement the positive test Malcolm suggests?
{ | ||
conn.Open(); | ||
|
||
Assert.Fail("Expected to use custom SSPI context provider"); |
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.
We should be able to use the test TDS Server for this. Implement a custom SSPI provider in the driver that just sends "Foo", have the TDS Server check for "Foo" and send back "Bar", and then have the custom provider check for "Bar" and complete the Open().
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.
Pull Request Overview
This PR exposes the SSPI context provider as a public API to allow custom authentication implementations. The change makes the SspiContextProvider
class and related types public so that developers can implement custom SSPI authentication logic.
- Converts internal SSPI-related classes to public APIs with proper documentation
- Adds a public property to SqlConnection for setting custom SSPI context providers
- Includes comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
SspiContextProvider.cs | Made class public and added XML documentation includes |
SspiAuthenticationParameters.cs | Made class public with documentation includes for all properties |
SqlConnection.cs (netfx & netcore) | Changed SspiContextProvider property from internal to public |
Microsoft.Data.SqlClient.cs (ref files) | Added public API definitions for both netfx and netcore |
IntegratedAuthenticationTest.cs | Added test for custom SSPI context provider functionality |
Microsoft.Data.SqlClient.sln | Added new documentation files to solution |
SspiContextProvider.xml | New XML documentation for SspiContextProvider |
SspiAuthenticationParameters.xml | New XML documentation for SspiAuthenticationParameters |
SqlConnection.xml | Added documentation for SspiContextProvider property |
Gets or sets the <see cref="SspiContextProvider"/> instance for customizing the SSPI context. If not set, the default for the platform will be used. | ||
</summary> | ||
<value> | ||
An <see cref="T:Micorosft.Data.SqlClient.SspiContextProvider" /> instance. |
Copilot
AI
Oct 8, 2025
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.
Corrected spelling of 'Micorosft' to 'Microsoft'.
An <see cref="T:Micorosft.Data.SqlClient.SspiContextProvider" /> instance. | |
An <see cref="T:Microsoft.Data.SqlClient.SspiContextProvider" /> instance. |
Copilot uses AI. Check for mistakes.
@twsouthwick I took the liberty of resolving the merge conflict. |
@benrr101 we still need a threat model review before we can take this change |
This change:
Fixes #2253