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

Expose SSPI context provider as public #2494

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

twsouthwick
Copy link
Member

Important

Stacked against #2454. Opened as a draft to enable validation, but since this is on a separate fork, GitHub does not support stacked PRs natively AFAIK

This change:

  • Adds a property to SqlConnection to allow setting a provider
  • Plumbs that property into the TdsParser so that it can be used if set

Fixes #2253

@twsouthwick twsouthwick changed the title Expose SSPI context provider as public Expose SSPI context provider as public May 8, 2024
As part of this change, the SSPIContextProvider base class now iterates through all the server names similar to what NegotiateSSPIContextProvider did.
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 78.31325% with 18 lines in your changes missing coverage. Please review.

Project coverage is 66.17%. Comparing base (9450fde) to head (cfcf164).

Files with missing lines Patch % Lines
...core/src/Microsoft/Data/SqlClient/SqlConnection.cs 61.53% 5 Missing ⚠️
...etfx/src/Microsoft/Data/SqlClient/SqlConnection.cs 54.54% 5 Missing ⚠️
...crosoft/Data/SqlClient/SSPI/SSPIContextProvider.cs 83.87% 5 Missing ⚠️
...t/Data/SqlClient/SSPI/NativeSSPIContextProvider.cs 66.66% 1 Missing ⚠️
...ata/SqlClient/SSPI/NegotiateSSPIContextProvider.cs 87.50% 1 Missing ⚠️
...c/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs 87.50% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (9450fde) and HEAD (cfcf164). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (9450fde) HEAD (cfcf164)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2494      +/-   ##
==========================================
- Coverage   72.76%   66.17%   -6.59%     
==========================================
  Files         287      281       -6     
  Lines       59173    58892     -281     
==========================================
- Hits        43055    38973    -4082     
- Misses      16118    19919    +3801     
Flag Coverage Δ
addons ?
netcore 69.14% <75.75%> (-6.32%) ⬇️
netfx 64.85% <67.27%> (-6.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

public abstract class SSPIContextProvider
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SSPIContextProvider.xml' path='docs/members[@name="SSPIContextProvider"]/GenerateSspiClientContext/*'/>
protected abstract void GenerateSspiClientContext(System.ReadOnlySpan<byte> incomingBlob, System.Buffers.IBufferWriter<byte> outgoingBlobWriter, SqlAuthenticationParameters authParams);
Copy link

Choose a reason for hiding this comment

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

Suggested change
protected abstract void GenerateSspiClientContext(System.ReadOnlySpan<byte> incomingBlob, System.Buffers.IBufferWriter<byte> outgoingBlobWriter, SqlAuthenticationParameters authParams);
protected abstract bool GenerateSspiClientContext(System.ReadOnlySpan<byte> incomingBlob, System.Buffers.IBufferWriter<byte> outgoingBlobWriter, SqlAuthenticationParameters authParams);

public abstract class SSPIContextProvider
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SSPIContextProvider.xml' path='docs/members[@name="SSPIContextProvider"]/GenerateSspiClientContext/*'/>
protected abstract void GenerateSspiClientContext(System.ReadOnlySpan<byte> incomingBlob, System.Buffers.IBufferWriter<byte> outgoingBlobWriter, SqlAuthenticationParameters authParams);
Copy link

Choose a reason for hiding this comment

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

Suggested change
protected abstract void GenerateSspiClientContext(System.ReadOnlySpan<byte> incomingBlob, System.Buffers.IBufferWriter<byte> outgoingBlobWriter, SqlAuthenticationParameters authParams);
protected abstract bool GenerateSspiClientContext(System.ReadOnlySpan<byte> incomingBlob, System.Buffers.IBufferWriter<byte> outgoingBlobWriter, SqlAuthenticationParameters authParams);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add hook for custom SSPI context for SqlConnection instances
2 participants