Azure / Azure/data-api-builder
[Enh]: Support Entra in Local Containers with `SQL_ACCESS_TOKEN`
- Ngôn ngữ chính
- C#
- Star
- 1.5k
- Fork
- 370
- Merge trung bình
- 3 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 9
Mô tả
## What
Allow Data API builder to read a development token from `SQL_ACCESS_TOKEN` and assign it to `SqlConnection.AccessToken`.
> [!IMPORTANT]
> This feature is explicitly scoped to development mode. Never use in production.
## Why
When DAB runs in Docker, normal Entra credential chains often fail. Some SQL endpoints, such as Fabric SQL, require token authentication. This feature provides a development token override so containerized development works without changing production authentication.
## How
- No change to the configuration file.
- No change to the command-line.
### At connection creation:
```
if (development mode &&
not OBO &&
Entra authentication &&
SQL_ACCESS_TOKEN exists)
{
connection.AccessToken = SQL_ACCESS_TOKEN
connection.Pooling = false
}
```
> [!IMPORTANT]
> The env var is re-read on every connection open (never cached).
> [!NOTE]
> In a pooled scenario, you might not see a clean error. So, we disable pooling.
### Logging
When properly invoked:
```
[INFO] Using SQL_ACCESS_TOKEN for connection (development mode)
```
When prerequisites are not met:
```
[WARN] SQL_ACCESS_TOKEN set but requirements are not met — token ignored
```
### Rules
* only when the connection string uses Microsoft Entra authentication: `Active Directory Default`, `Active Directory Managed Identity`, `Active Directory Workload Identity` only.
* only when the `OBO` flow is not being used
* only when `SQL_ACCESS_TOKEN` exists
* only when `runtime.host.mode=development`
* always allow the engine to start
* let the database raise connection errors if the token is invalid
* do not cache the token, re-read it every time a connection is opened
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu từ đường dẫn tạo kết nối và theo dõi các kiểm tra về chế độ phát triển, OBO và xác thực Microsoft Entra. Xác minh rằng SQL_ACCESS_TOKEN được đọc lại cho mỗi kết nối, việc pooling bị vô hiệu hóa khi token này được sử dụng và info hoặc warning được chỉ định được ghi vào log. Xác nhận rằng các điều kiện tiên quyết chưa được đáp ứng không ngăn cản quá trình khởi động và các token không hợp lệ được để cho cơ sở dữ liệu từ chối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- azure, csharp, sql
- Lĩnh vực
- authentication, backend-api-design, databases
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100