-
Notifications
You must be signed in to change notification settings - Fork 321
WAM POC #2884
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
WAM POC #2884
Changes from all commits
c4e5c4a
6b0a7b9
f2022ae
14767bc
37d77ee
86d23d4
b5ceede
4fbdd68
c32327d
dd3df24
0ded77a
3fbce21
3b08acf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -73,7 +73,7 @@ | |||||||||||||||||||||||||||||||||||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" /> | ||||||||||||||||||||||||||||||||||||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" /> | ||||||||||||||||||||||||||||||||||||||
| <PropertyGroup Condition="$(Configuration.Contains('Debug'))"> | ||||||||||||||||||||||||||||||||||||||
| <DefineConstants>$(DefineConstants);DEBUG;DBG;_DEBUG;_LOGGING;RESOURCE_ANNOTATION_WORK;</DefineConstants> | ||||||||||||||||||||||||||||||||||||||
| <DefineConstants>$(DefineConstants);DEBUG;DBG;_DEBUG;_LOGGING;RESOURCE_ANNOTATION_WORK;INTERACTIVE_AUTH;</DefineConstants> | ||||||||||||||||||||||||||||||||||||||
| <DebugType>Full</DebugType> | ||||||||||||||||||||||||||||||||||||||
| <Optimize>False</Optimize> | ||||||||||||||||||||||||||||||||||||||
| </PropertyGroup> | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -82,6 +82,12 @@ | |||||||||||||||||||||||||||||||||||||
| <DebugType>Pdbonly</DebugType> | ||||||||||||||||||||||||||||||||||||||
| <Optimize>True</Optimize> | ||||||||||||||||||||||||||||||||||||||
| </PropertyGroup> | ||||||||||||||||||||||||||||||||||||||
| <PropertyGroup> | ||||||||||||||||||||||||||||||||||||||
| <DefineConstants>$(DefineConstants);NETFRAMEWORK;</DefineConstants> | ||||||||||||||||||||||||||||||||||||||
| </PropertyGroup> | ||||||||||||||||||||||||||||||||||||||
| <PropertyGroup Condition="'$(InteractiveAuthEnabled)'=='true'"> | ||||||||||||||||||||||||||||||||||||||
| <DefineConstants>$(DefineConstants);INTERACTIVE_AUTH;</DefineConstants> | ||||||||||||||||||||||||||||||||||||||
| </PropertyGroup> | ||||||||||||||||||||||||||||||||||||||
| <ItemGroup> | ||||||||||||||||||||||||||||||||||||||
| <Reference Include="System" /> | ||||||||||||||||||||||||||||||||||||||
| <Reference Include="System.Configuration" /> | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1069,6 +1075,21 @@ | |||||||||||||||||||||||||||||||||||||
| <PrivateAssets>All</PrivateAssets> | ||||||||||||||||||||||||||||||||||||||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||||||||||||||||||||||||||||||||||||||
| </PackageReference> | ||||||||||||||||||||||||||||||||||||||
| <PackageReference Include="Azure.Identity"> | ||||||||||||||||||||||||||||||||||||||
| <Version>$(AzureIdentityVersion)</Version> | ||||||||||||||||||||||||||||||||||||||
| </PackageReference> | ||||||||||||||||||||||||||||||||||||||
| <PackageReference Include="Microsoft.Identity.Client.Broker" Condition="$(DefineConstants.Contains('INTERACTIVE_AUTH'))"> | ||||||||||||||||||||||||||||||||||||||
| <Version>$(MicrosoftIdentityClientBrokerVersion)</Version> | ||||||||||||||||||||||||||||||||||||||
| </PackageReference> | ||||||||||||||||||||||||||||||||||||||
| <PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect"> | ||||||||||||||||||||||||||||||||||||||
| <version>$(MicrosoftIdentityModelProtocolsOpenIdConnectVersion)</version> | ||||||||||||||||||||||||||||||||||||||
| </PackageReference> | ||||||||||||||||||||||||||||||||||||||
| <PackageReference Include="Microsoft.IdentityModel.JsonWebTokens"> | ||||||||||||||||||||||||||||||||||||||
| <version>$(MicrosoftIdentityModelJsonWebTokensVersion)</version> | ||||||||||||||||||||||||||||||||||||||
| </PackageReference> | ||||||||||||||||||||||||||||||||||||||
| <PackageReference Include="System.Buffers"> | ||||||||||||||||||||||||||||||||||||||
| <Version>$(SystemBuffersVersion)</Version> | ||||||||||||||||||||||||||||||||||||||
| </PackageReference> | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1078
to
+1092
|
||||||||||||||||||||||||||||||||||||||
| <PackageReference Include="Azure.Identity"> | |
| <Version>$(AzureIdentityVersion)</Version> | |
| </PackageReference> | |
| <PackageReference Include="Microsoft.Identity.Client.Broker" Condition="$(DefineConstants.Contains('INTERACTIVE_AUTH'))"> | |
| <Version>$(MicrosoftIdentityClientBrokerVersion)</Version> | |
| </PackageReference> | |
| <PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect"> | |
| <version>$(MicrosoftIdentityModelProtocolsOpenIdConnectVersion)</version> | |
| </PackageReference> | |
| <PackageReference Include="Microsoft.IdentityModel.JsonWebTokens"> | |
| <version>$(MicrosoftIdentityModelJsonWebTokensVersion)</version> | |
| </PackageReference> | |
| <PackageReference Include="System.Buffers"> | |
| <Version>$(SystemBuffersVersion)</Version> | |
| </PackageReference> | |
| <PackageReference Include="Microsoft.Identity.Client.Broker" Condition="$(DefineConstants.Contains('INTERACTIVE_AUTH'))"> | |
| <Version>$(MicrosoftIdentityClientBrokerVersion)</Version> | |
| </PackageReference> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| internal partial class Interop | ||
| { | ||
| internal partial class Kernel32 | ||
| { | ||
| [DllImport("kernel32.dll")] | ||
| internal static extern IntPtr GetConsoleWindow(); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
|
|
||
| internal partial class Interop | ||
| { | ||
| internal partial class User32 | ||
| { | ||
| internal enum GetAncestorFlags | ||
| { | ||
| GetParent = 1, | ||
| GetRoot = 2, | ||
| /// <summary> | ||
| /// Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent. | ||
| /// </summary> | ||
| GetRootOwner = 3 | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Retrieves the handle to the ancestor of the specified window. | ||
| /// </summary> | ||
| /// <param name="hwnd">A handle to the window whose ancestor is to be retrieved. | ||
| /// If this parameter is the desktop window, the function returns NULL. </param> | ||
| /// <param name="flags">The ancestor to be retrieved.</param> | ||
| /// <returns>The return value is the handle to the ancestor window.</returns> | ||
| [DllImport("user32.dll", ExactSpelling = true)] | ||
| internal static extern IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags flags); | ||
|
||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||
| using System; | ||||||||||||||
| using System.Threading; | ||||||||||||||
|
||||||||||||||
| using System.Threading; |
Copilot
AI
Jan 7, 2026
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.
The Unix implementation returns null when _parentActivityOrWindowFunc is null, but there's no corresponding SetParentActivityOrWindow method in the Unix partial class. This creates an API inconsistency between Windows and Unix platforms. Users who call SetParentActivityOrWindow on Unix will encounter a compile error, but the property ParentActivityOrWindow will always return null, which may cause issues when interactive authentication is attempted on Unix (if supported). Consider either adding a stub implementation or documenting the platform-specific behavior.
| public void SetParentActivityOrWindow(Func<object> parentActivityOrWindowFunc) | |
| { | |
| _parentActivityOrWindowFunc = parentActivityOrWindowFunc; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||||||||||||||
| using System; | ||||||||||||||||||
|
|
||||||||||||||||||
| namespace Microsoft.Data.SqlClient | ||||||||||||||||||
| { | ||||||||||||||||||
| public sealed partial class ActiveDirectoryAuthenticationProvider : SqlAuthenticationProvider | ||||||||||||||||||
| { | ||||||||||||||||||
| private Func<object> _parentActivityOrWindowFunc = null; | ||||||||||||||||||
|
|
||||||||||||||||||
| private Func<object> ParentActivityOrWindow | ||||||||||||||||||
| { | ||||||||||||||||||
| get | ||||||||||||||||||
| { | ||||||||||||||||||
| return _parentActivityOrWindowFunc != null ? _parentActivityOrWindowFunc : GetConsoleOrTerminalWindow; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| set | ||||||||||||||||||
| { | ||||||||||||||||||
| _parentActivityOrWindowFunc = value; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| #if NETFRAMEWORK | ||||||||||||||||||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/ActiveDirectoryAuthenticationProvider.xml' path='docs/members[@name="ActiveDirectoryAuthenticationProvider"]/SetIWin32WindowFunc/*'/> | ||||||||||||||||||
| public void SetIWin32WindowFunc(Func<System.Windows.Forms.IWin32Window> iWin32WindowFunc) => SetParentActivityOrWindow(iWin32WindowFunc); | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
|
||||||||||||||||||
| /// <summary> | ||||||||||||||||||
| /// | ||||||||||||||||||
| /// </summary> | ||||||||||||||||||
| /// <param name="parentActivityOrWindowFunc"></param> | ||||||||||||||||||
|
Comment on lines
+28
to
+30
|
||||||||||||||||||
| /// | |
| /// </summary> | |
| /// <param name="parentActivityOrWindowFunc"></param> | |
| /// Sets the delegate used to obtain the parent activity or window for interactive authentication prompts. | |
| /// </summary> | |
| /// <param name="parentActivityOrWindowFunc"> | |
| /// A function that returns an object representing the parent activity or window handle to associate with UI dialogs. | |
| /// </param> |
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.
The INTERACTIVE_AUTH constant is unconditionally defined in Debug configurations (line 76) but conditionally defined based on InteractiveAuthEnabled property in line 89. This creates a conflict where INTERACTIVE_AUTH will always be defined in Debug builds regardless of the InteractiveAuthEnabled setting. The unconditional definition on line 76 should be removed to respect the InteractiveAuthEnabled property setting.