Skip to content

[6.1] Ensure correct SPN when calling SspiContextProvider (#3347) #3478

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

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

mdaigle
Copy link
Contributor

@mdaigle mdaigle commented Jul 15, 2025

Description

Ports #3347 to release/6.1

* Reset negotiateAuth if SNI doesn't work

This change also adds some book keeping to ensure we're only using the spn that has previously generated a context once one has been created.

* initialization only after success

* move serverSpn to be local
@mdaigle mdaigle marked this pull request as ready for review July 15, 2025 16:04
@Copilot Copilot AI review requested due to automatic review settings July 15, 2025 16:04
@mdaigle mdaigle requested a review from a team as a code owner July 15, 2025 16:04
@mdaigle mdaigle added this to the 6.1.0 milestone Jul 15, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 ports changes from #3347 to the release/6.1 branch to ensure correct SPN (Service Principal Name) handling when calling SspiContextProvider. The changes improve SPN management by introducing a new data structure to hold primary and secondary SPNs and refactoring the authentication flow to use this improved approach.

  • Refactors SPN handling from string arrays to a new ResolvedServerSpn struct that holds primary and secondary SPNs
  • Updates SspiContextProvider to pre-initialize authentication parameters with correct SPNs instead of passing them at call time
  • Adds proper disposal pattern for NegotiateSspiContextProvider to manage resources correctly

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ResolvedServerSpn.cs New struct to encapsulate primary and secondary SPN values with detailed documentation
SspiContextProvider.cs Refactored to store authentication parameters during initialization and simplified API methods
NegotiateSspiContextProvider.cs Added IDisposable implementation and SPN validation logic
TdsParser.cs (both versions) Updated to use new SPN resolution approach and moved authentication provider initialization
SniProxy.netcore.cs Changed return type from string array to ResolvedServerSpn struct
InstanceNameTest.cs Updated test to work with new SPN resolution API
SqlClientEventSource.cs Added new overload for three-parameter state dump events

Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

🚀 👕

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

Attention: Patch coverage is 69.81132% with 16 lines in your changes missing coverage. Please review.

Project coverage is 64.71%. Comparing base (6773a65) to head (ee26b82).
Report is 3 commits behind head on release/6.1.

Files with missing lines Patch % Lines
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 0.00% 6 Missing ⚠️
...crosoft/Data/SqlClient/SSPI/SspiContextProvider.cs 73.68% 5 Missing ⚠️
...ata/SqlClient/SSPI/NegotiateSspiContextProvider.cs 70.00% 3 Missing ⚠️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 80.00% 1 Missing ⚠️
...soft/Data/SqlClient/ManagedSni/SniProxy.netcore.cs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/6.1    #3478      +/-   ##
===============================================
- Coverage        68.87%   64.71%   -4.17%     
===============================================
  Files              280      281       +1     
  Lines            62322    62354      +32     
===============================================
- Hits             42927    40351    -2576     
- Misses           19395    22003    +2608     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 68.94% <78.72%> (-3.84%) ⬇️
netfx 66.18% <62.06%> (-1.88%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@benrr101 benrr101 merged commit 0b8eb64 into release/6.1 Jul 15, 2025
129 checks passed
@benrr101 benrr101 deleted the dev/mdaigle/port-3347 branch July 15, 2025 23:00
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.

4 participants