Skip to content

Commit 7a3d49a

Browse files
committed
Task 41895: Complete Step 4 PR
- Addressed comments from Step 3 PR.
1 parent 362533b commit 7a3d49a

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

Directory.Packages.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider"
3434
Version="$(AkvPackageVersion)" />
3535
</ItemGroup>
36-
36+
3737
<!-- ===================================================================== -->
3838
<!-- Shared Dependencies -->
3939

4040
<!-- Public -->
4141
<ItemGroup>
42-
<!-- MDS and AKV -->
42+
<!-- MDS, Azure, and AKV -->
4343
<PackageVersion Include="Azure.Core" Version="1.49.0" />
4444
<PackageVersion Include="Microsoft.Identity.Client" Version="4.78.0" />
4545
</ItemGroup>
@@ -49,7 +49,7 @@
4949
<!-- MDS and AKV -->
5050
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.9" />
5151
</ItemGroup>
52-
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
52+
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
5353
<!-- MDS and AKV -->
5454
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
5555
</ItemGroup>
@@ -105,13 +105,12 @@
105105

106106
<!-- Common Dependencies (.NET and .NET Framework) -->
107107
<ItemGroup>
108-
<PackageVersion Include="Azure.Identity" Version="1.17.0" />
109108
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.14.0" />
110109
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.14.0" />
111110
</ItemGroup>
112111

113112
<!-- Common Target Framework Specific Dependencies -->
114-
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
113+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
115114
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="9.0.9" />
116115
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.9" />
117116
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.9" />
@@ -143,6 +142,9 @@
143142
<!-- Azure Dependencies -->
144143

145144
<!-- None -->
145+
<ItemGroup>
146+
<PackageVersion Include="Azure.Identity" Version="1.17.0" />
147+
</ItemGroup>
146148

147149
<!-- ===================================================================== -->
148150
<!-- AKV Dependencies -->

src/Microsoft.Data.SqlClient.Extensions/Azure/src/Azure.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
</ItemGroup>
9696

9797
<ItemGroup>
98+
<PackageReference Include="Azure.Core" />
9899
<PackageReference Include="Azure.Identity" />
99100
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
100101
</ItemGroup>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,6 +2860,20 @@ private SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
28602860

28612861
// Fall through to retry...
28622862
}
2863+
// If the provider throws anything else, it's an API violation, which we must
2864+
// consume to avoid breaking our API promise.
2865+
catch (Exception ex)
2866+
{
2867+
throw ADP.CreateSqlException(
2868+
new ProviderApiViolationException(
2869+
message:
2870+
"API violation; provider threw unexpected exception " +
2871+
ex.GetType().FullName + ": " + ex.Message,
2872+
causedBy: ex),
2873+
ConnectionOptions,
2874+
this,
2875+
username);
2876+
}
28632877
}
28642878

28652879
// Nullable context has exposed that _fedAuthToken may be null here,
@@ -2887,6 +2901,15 @@ private SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
28872901
return _fedAuthToken;
28882902
}
28892903

2904+
// Thrown when an authentication provider violates the expected API contract.
2905+
private class ProviderApiViolationException : SqlAuthenticationProviderException
2906+
{
2907+
public ProviderApiViolationException(string message, Exception causedBy)
2908+
: base(message, causedBy)
2909+
{
2910+
}
2911+
}
2912+
28902913
#nullable disable
28912914

28922915
private void Login(

tools/specs/Microsoft.Data.SqlClient.nuspec

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636

3737
<dependencies>
3838
<group targetFramework="net462">
39-
<dependency id="Azure.Core" version="1.49.0" />
40-
<dependency id="Azure.Identity" version="1.16.0" />
4139
<dependency id="Microsoft.Bcl.Cryptography" version="8.0.0" />
4240
<dependency id="Microsoft.Data.SqlClient.Extensions.Abstractions" version="$AbstractionsPackageVersion$" />
4341
<dependency id="Microsoft.Data.SqlClient.SNI" version="6.0.2" />
@@ -54,8 +52,6 @@
5452
<dependency id="System.ValueTuple" version="4.6.1" />
5553
</group>
5654
<group targetFramework="net8.0">
57-
<dependency id="Azure.Core" version="1.49.0" />
58-
<dependency id="Azure.Identity" version="1.16.0" />
5955
<dependency id="Microsoft.Bcl.Cryptography" version="8.0.0" />
6056
<dependency id="Microsoft.Data.SqlClient.Extensions.Abstractions" version="$AbstractionsPackageVersion$" />
6157
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="6.0.2" exclude="Compile" />
@@ -67,8 +63,6 @@
6763
<dependency id="System.Security.Cryptography.Pkcs" version="8.0.1" />
6864
</group>
6965
<group targetFramework="net9.0">
70-
<dependency id="Azure.Core" version="1.49.0" />
71-
<dependency id="Azure.Identity" version="1.16.0" />
7266
<dependency id="Microsoft.Bcl.Cryptography" version="9.0.9" />
7367
<dependency id="Microsoft.Data.SqlClient.Extensions.Abstractions" version="$AbstractionsPackageVersion$" />
7468
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="6.0.2" exclude="Compile" />
@@ -80,8 +74,6 @@
8074
<dependency id="System.Security.Cryptography.Pkcs" version="9.0.9" />
8175
</group>
8276
<group targetFramework="netstandard2.0">
83-
<dependency id="Azure.Core" version="1.49.0" />
84-
<dependency id="Azure.Identity" version="1.16.0" />
8577
<dependency id="Microsoft.Bcl.Cryptography" version="8.0.0" />
8678
<dependency id="Microsoft.Data.SqlClient.Extensions.Abstractions" version="$AbstractionsPackageVersion$" />
8779
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="6.0.2" exclude="Compile" />

0 commit comments

Comments
 (0)