Azure / Azure/data-api-builder

[Enh]: Support Entra in Local Containers with `SQL_ACCESS_TOKEN`

Aperta
#3,252 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
2.x
Lingua principale
C#
Stelle
1.5k
Fork
370
Merge medio
3g 17h
PR unite (30g)
8

Descrizione

## 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dal percorso di creazione delle connessioni e segui i controlli della modalità di sviluppo, di OBO e dell'autenticazione Microsoft Entra. Verifica che SQL_ACCESS_TOKEN venga riletto per ogni connessione, che il pooling venga disabilitato quando viene utilizzato e che vengano registrati l'info o l'avviso specificati. Conferma che i prerequisiti non soddisfatti non impediscano l'avvio e che i token non validi vengano lasciati al database perché li rifiuti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, csharp, sql
Ambito
authentication, backend-api-design, databases
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.