runtime icon indicating copy to clipboard operation
runtime copied to clipboard

SqlConnection should support Azure AD token-based authentication

Open ndavidsmk opened this issue 10 years ago • 36 comments

The desktop .NET Framework 4.6 and newer has an AccessToken property on the SqlConnection class (MSDN) which can be used to authenticate to a SQL Azure database using an access token issued by Azure AD (examples here). However, this property is not present on the version of SqlConnection provided in the System.Data.SqlClient NuGet package, including the latest preview v4.3.0-preview1-24530-04. In case it's an important detail, the project in question is a library project targeting 'netstandard1.6'.

The lack of the AccessToken property makes it difficult, if not impossible, to support modern directory-based auth scenarios for Azure SQL DB while also targeting .NET Standard (I have not attempted to use the connection string-based AAD options, but for various reasons those would not be applicable for my project). I have yet to find a workaround other than setting the target framework to 'net46', which I would like to avoid except as a last resort.

ndavidsmk avatar Nov 15 '16 00:11 ndavidsmk

Related to dotnet/SqlClient#10

saurabh500 avatar Nov 15 '16 03:11 saurabh500

It's a bit strange that Azure is such a huge and important part of Microsoft, but .NET Standard and .NET Core aren't given the necessary resources to support it.

I don't mean to blame anyone here, it's just that I'd love to use .NET Core but still cannot do so more than 3 years after it was announced.

stijnherreman avatar Mar 15 '18 12:03 stijnherreman

The PR referred to by @keeratsingh is https://github.com/dotnet/corefx/pull/30342

stijnherreman avatar Jun 21 '18 11:06 stijnherreman

@nathandavidson @stijnherreman Closing this is issue since it is addressed by pr #30342.

AfsanehR-zz avatar Jun 27 '18 16:06 AfsanehR-zz

@AfsanehR: great! So this will be released in .NET Core 2.2?

Liero avatar Jun 28 '18 07:06 Liero

Security should be number 1. This should have been released already.

BruceHunter avatar Jul 08 '18 14:07 BruceHunter

The PR was merged into master, which will ship in 3.0. I let @AfsanehR @David-Engel @keeratsingh to comment on option porting it to 2.2.

karelz avatar Jul 08 '18 19:07 karelz

I think everyone waiting for this would like to see it in 2.2.

stijnherreman avatar Jul 10 '18 13:07 stijnherreman

How this implementation will impact the pool connection key ? If there is two differents AccessToken with the same connection string, does it mean that they can share the same connection pool or not ?

Trontin avatar Jul 24 '18 12:07 Trontin

A new connection pool is created for every access token.

saurabh500 avatar Jul 24 '18 14:07 saurabh500

+1 for getting this into .NET Core 2.2. By the time 2.2 comes out this issue will be 2 years old.

paulirwin avatar Jul 26 '18 13:07 paulirwin

@AfsanehR @David-Engel @keeratsingh any decision on whether this update will be ported to 2.2?

wienleung avatar Aug 04 '18 01:08 wienleung

@wienleung @Liero @paulirwin @stijnherreman We are currently in the process of porting this fix over to .NET Core 2.2, will updated here once the process is complete.

keeratsingh avatar Aug 07 '18 16:08 keeratsingh

Reopening the issue to track port to 2.2 (PR dotnet/corefx#31039).

karelz avatar Aug 16 '18 17:08 karelz

The AccessToken property is now added to .NET Core 2.2. 🎉

EDIT: While the PR was merged into the branch prior to 2.2 Preview1 release, it missed packaging changes and the package didn't ship at all, so it will be part of 2.2 Preview2 release (released on 2018/9/12).

AfsanehR-zz avatar Aug 17 '18 16:08 AfsanehR-zz

Thanks @AfsanehR for addressing this popular issue. For those who will ask: we have not AFAIK announced a date for 2.2 yet. It will definitely be before 3.0 😀 Meantime, if anyone has a chance to try this out of the repo (either master or release/2.2) it would be great if you could indicate here to confirm you were successful.

danmoseley avatar Aug 17 '18 17:08 danmoseley

2.2. is currently planned for Q4 2018: https://github.com/dotnet/core/blob/master/roadmap.md#upcoming-ship-dates

karelz avatar Aug 17 '18 17:08 karelz

Can you give us an update on when we should be able to test this feature/start using it in development. Would that be 2.2.100-preview2?

bloodybeet avatar Sep 11 '18 07:09 bloodybeet

Why can't this be distributed as a nuget package as opposed to with the full core sdk?

jnevins-gcm avatar Sep 11 '18 14:09 jnevins-gcm

@jnevins-gcm shipping standalone packages leads to test matrix explosion + things don't work properly together when they should, etc. It caused lots of troubles for both the customers and the team and with .NET Core we started shipping platform as single NuGet package. You can check the feature in daily builds of release/2.2 build, or wait for next preview which will contain the fix (based on times and the schedule I am aware of, it should be Preview2).

karelz avatar Sep 11 '18 16:09 karelz