You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[OBO] Add CLI support for user-delegated authentication configuration (#3128)
## Why make this change?
Implements CLI configuration for OBO (On-Behalf-Of) delegated identity
as specified in #2898. The OBO core implementation was merged into main
via PR #3151. This PR adds CLI commands to enable operators to configure
per-user Entra ID authentication to Azure SQL and SQL Server via CLI
instead of manual config file editing.
## What is this change?
**CLI Commands Added**
- `dab configure --data-source.user-delegated-auth.enabled true` -
Enable/disable OBO authentication for Azure SQL and SQL Server
- `dab configure --data-source.user-delegated-auth.database-audience
"https://database.windows.net"` - Configure database resource identifier
for token acquisition
**Implementation Details**
- Updated `ConfigureOptions.cs` with two new CLI option parameters
(`dataSourceUserDelegatedAuthEnabled`,
`dataSourceUserDelegatedAuthDatabaseAudience`)
- Updated `ConfigGenerator.TryUpdateConfiguredDataSourceOptions()` to
create/update `UserDelegatedAuthOptions` configuration
- Added validation to ensure user-delegated-auth is only used with MSSQL
database type
- Provider field automatically defaults to "EntraId" when
user-delegated-auth is configured
- Preserves existing user-delegated-auth configuration when updating
individual fields
- Help text clarifies support for both Azure SQL and on-premises SQL
Server
**Configuration Output**
The CLI generates configuration that integrates with the
`UserDelegatedAuthOptions` from the merged OBO implementation:
```json
{
"data-source": {
"database-type": "mssql",
"connection-string": "...",
"user-delegated-auth": {
"enabled": true,
"provider": "EntraId",
"database-audience": "https://database.windows.net"
}
}
}
```
**Files Changed (5 CLI-specific files)**
- `src/Cli/Commands/ConfigureOptions.cs` - CLI option definitions with
SQL Server on-premises support
- `src/Cli/ConfigGenerator.cs` - Configuration update logic
- `src/Cli.Tests/ConfigureOptionsTests.cs` - Consolidated CLI
configuration tests
- `src/Cli.Tests/UserDelegatedAuthRuntimeParsingTests.cs` - 2 runtime
parsing tests
- `src/Cli.Tests/TestHelper.cs` - Added CONFIG_WITH_USER_DELEGATED_AUTH
test constant
## How was this tested?
- [x] Unit Tests - 9 tests total:
- 3 parameterized CLI configuration tests (enabled only, audience only,
both together)
- 1 update test with JSON structure validation (verifies proper nesting
under data-source with correct property names)
- 3 validation error tests (PostgreSQL, MySQL, CosmosDB rejection)
- 2 runtime parsing tests (verify CLI-generated config loads correctly)
- Tests verify default values for properties not explicitly set (Enabled
defaults to false, DatabaseAudience defaults to null)
- [x] Integration Tests - Verified MSSQL-only validation with
PostgreSQL/MySQL/CosmosDB rejection scenarios
## Sample Request(s)
**Initialize and configure OBO in one workflow:**
```bash
# Initialize MSSQL config
dab init --database-type mssql --connection-string "Server=myserver.database.windows.net;Database=mydb"
# Enable user-delegated auth with both options
dab configure --data-source.user-delegated-auth.enabled true \
--data-source.user-delegated-auth.database-audience "https://database.windows.net"
```
**Update audience for existing configuration:**
```bash
dab configure --data-source.user-delegated-auth.database-audience "https://database.usgovcloudapi.net"
```
**Update only the enabled flag:**
```bash
dab configure --data-source.user-delegated-auth.enabled false
```
**Validation - fails for non-MSSQL:**
```bash
dab init --database-type postgresql --connection-string "..."
dab configure --data-source.user-delegated-auth.enabled true
# Error: user-delegated-auth is only supported for database-type 'mssql'.
```
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>[OBO] CLI Support for Enabling OBO Delegated
Identity</issue_title>
> <issue_description>Implement CLI support for enabling OBO exactly as
defined in the design.
>
> - These CLI Commands should be supported
> `dab configure --data-source.user-delegated-auth.enabled true`
> `dab configure --data-source.user-delegated-auth.database-audience
"<audience>"`
>
> - Ensure CLI writes correct config structure
> - Ensure runtime consumes CLI‑produced config
>
> Testing:
> 1. CLI sets user-delegated-auth.enabled = true
> 2. CLI sets correct database-audience
> 3. runtime reads CLI output correctly
> 4. invalid CLI input fails deterministically</issue_description>
>
>
<agent_instructions>https://microsoft-my.sharepoint.com/:w:/p/anushakolan/IQDsb4patJ52Q65Cp0QHQ-b_Aazplc1go_6k2HccCOYLQNU?e=Bpuv1Z&wdOrigin=TEAMS-MAGLEV.null_ns.rwc&wdExp=TEAMS-TREATMENT&wdhostclicktime=1770765689642&web=1
>
> Follow this design document for more context and questions, understand
the requirement of the task, this is the main task,
#2898, create the PR
accordingly.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes#3127
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: anushakolan <[email protected]>
Co-authored-by: Anusha Kolan <[email protected]>
Co-authored-by: Aniruddh Munde <[email protected]>
[DataRow(true,"https://database.windows.net",DisplayName="Set both enabled and database-audience")]
[Option("runtime.graphql.depth-limit",Required=false,HelpText="Max allowed depth of the nested query. Allowed values: (0,2147483647] inclusive. Default is infinity. Use -1 to remove limit.")]
0 commit comments