Repository navigation
Use DAB's client ID for SqlClient Entra ID authentication - #3927
Cheena Malhotra (cheenamalhotra) wants to merge 1 commit into
Conversation
Use DAB_OBO_CLIENT_ID for SqlClient's ActiveDirectoryAuthenticationProvider across all supported authentication modes instead of SqlClient's default application. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues requiring changes.
No open issues 🎉
What changed in this PR
This PR configures DAB’s SQL Server authentication to use DAB_OBO_CLIENT_ID for SqlClient public-client flows when set, rather than relying on SqlClient’s built-in application identity.
Changes:
- Adds shared authentication-provider registration, preserving existing providers when the client ID is unset or blank.
- Registers providers during runtime executor initialization and CLI autoentities simulation.
- Documents the client ID’s scope and adds tests for registration and unchanged-provider behavior.
| File | Description |
|---|---|
src/Core/Resolvers/MsSqlQueryExecutor.cs |
Registers SqlClient authentication providers during executor initialization. |
src/Core/AuthenticationHelpers/SqlClientAuthentication.cs |
Adds shared provider registration using the configured client ID. |
src/Config/ObjectModel/DataSource.cs |
Documents SqlClient usage and authentication scope of the environment variable. |
src/Cli/ConfigGenerator.cs |
Registers providers before CLI autoentities simulation opens a connection. |
src/Cli.Tests/SqlClientAuthenticationTests.cs |
Tests provider registration and preservation when no client ID is configured. |
Review effort: Balanced
| internal static void RegisterProviders() | ||
| { | ||
| string? clientId = Environment.GetEnvironmentVariable(UserDelegatedAuthOptions.DAB_OBO_CLIENT_ID_ENV_VAR); | ||
| if (string.IsNullOrWhiteSpace(clientId)) |
There was a problem hiding this comment.
this is an important fallback, if OBO is not enabled/setup, this clientId will be null. Just want to make sure, in that situation, the existing default app client id will still be valid for EntraAuth modes, right?
There was a problem hiding this comment.
when SqlClient drops support for non-WAM broker enabled workflows by removing localhost reply URLs, would this fallback scenario continue to work when OBO is not enabled?
Aniruddh Munde (Aniruddh25)
left a comment
There was a problem hiding this comment.
Looks good with respect to the isolated change for OBO flow. Left few questions for clarification.
Why make this change?
Authentication=Active Directory ...connection strings, SqlClient falls back to its built-in application (ActiveDirectoryAuthentication.AdoClientId).What is this change?
SqlClientAuthentication.RegisterProviders()insrc/Core/AuthenticationHelpers/SqlClientAuthentication.cs.DAB_OBO_CLIENT_IDis set, DAB creates oneActiveDirectoryAuthenticationProvider(clientId). It registers that provider viaSqlAuthenticationProvider.SetProviderfor everySqlAuthenticationMethodthe provider supports.DAB_OBO_CLIENT_IDis not set or is blank, nothing changes and SqlClient's existing providers are kept.SetProvideris rejected because app config already set a provider that can't be overridden, startup fails with a clear error. This avoids silently using SqlClient's application.MsSqlQueryExecutorconstructor (runtime);ConfigGenerator, before it opens aSqlConnection.DAB_OBO_CLIENT_ID_ENV_VARdoc inDataSource.cs.ActiveDirectoryAuthenticationProvider:User Idas their identity, so they are unaffected. DAB'sDefaultAzureCredentialaccess-token path is also unaffected.How was this tested?
src/Cli.Tests/SqlClientAuthenticationTests.cs(runs on its own and restores global state afterwards). It checks that:dotnet test src\Cli.Tests\Cli.Tests.csproj --filter "FullyQualifiedName~SqlClientAuthenticationTests|FullyQualifiedName~UserDelegatedAuthRuntimeParsingTests": passed (6/6)SqlQueryExecutorUnitTests.TestHandleManagedIdentityAccess|OboCredentialFactoryTests: passed (56/56)dotnet format whitespace --verify-no-changeson the changed files: cleanSample Request(s)
DAB_OBO_CLIENT_ID=<your-app-registration-client-id>and use an Entra ID connection string, for exampleServer=...;Database=...;Authentication=Active Directory Interactive;. SqlClient then signs in with DAB's configured application instead of SqlClient's built-in application.