Azure / Azure/data-api-builder

Postgresql database connection with Workload Identity in an AKS deployment

Abierto
#2,271 1 comentario 0 reacciones 0 asignados Ver en GitHub
cri enhancement
Lenguaje dominante
C#
Estrellas
1.5k
Forks
370
Merge medio
3 d 22 h
PR fusionados (30 d)
9

Descripción

### What happened?

I am able to deploy the DAB container in an AKS cluster and mount the configfile, which is loaded.
Our preferred policy is to use a workload identity to authenticate with the Postgresql Flexible server database.

Connection string, via environment variable injected in dab-config.json. The client id gets replaced at deploy time via Helm:

`"Host=psqlf-demo....postgres.database.azure.com;Port=5432;Database=demo;SSL Mode=Require;User Id={{.Value.serviceAccount.clientId}}"`

Part of the config file:
` "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.1.7/dab.draft.schema.json",
"data-source": {
"database-type": "postgresql",
"connection-string": "@env('DATABASE_CONNECTION')"
},
"runtime": {
"host": {
"mode": "development"
}`

According to source code, an Azure identity is assumed when the connection string does not contain a password.
Startup fails with a 28P01: password authentication failed for

I might be missing the option to explicitly inform DAB to use Azure authentication instead of regular username/password authentication.

### Version

1.1.7

### What database are you using?

PostgreSQL

### What hosting model are you using?

Custom Docker host

### Which API approach are you accessing DAB through?

REST, GraphQL

### Relevant log output

```Text
info: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
[monsters] REST path: /api/monsters
fail: Azure.DataApiBuilder.Service.Startup[0]
Unable to complete runtime initialization. Refer to exception for error details.
Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: Cannot obtain Schema for entity monsters with underlying database object source: monsters.monsters due to: 28P01: password authentication failed for user "b8c2bf96-..."
at Azure.DataApiBuilder.Core.Services.SqlMetadataProvider`3.HandleOrRecordException(Exception e) in /_/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs:line 100
at Azure.DataApiBuilder.Core.Services.SqlMetadataProvider`3.PopulateObjectDefinitionForEntity(String entityName, Entity entity) in /_/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs:line 1116
at Azure.DataApiBuilder.Core.Services.SqlMetadataProvider`3.PopulateObjectDefinitionForEntities() in /_/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs:line 1054
at Azure.DataApiBuilder.Core.Services.SqlMetadataProvider`3.InitializeAsync() in /_/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs:line 289
at Azure.DataApiBuilder.Core.Services.MetadataProviders.MetadataProviderFactory.InitializeAsync() in /_/src/Core/Services/MetadataProviders/MetadataProviderFactory.cs:line 65
at Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder app) in /_/src/Service/Startup.cs:line 613
fail: Azure.DataApiBuilder.Service.Startup[0]
Could not initialize the engine with the runtime config file: dab-config.json
```

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con el manejo de la conexión y la identidad de PostgreSQL al que se hace referencia en src/Core/Services/MetadataProviders/SqlMetadataProvider.cs, especialmente con las ubicaciones del stack trace alrededor de las líneas 100 y 1116. Reproduce la configuración de AKS usando dab-config.json y la variable de entorno DATABASE_CONNECTION. Se considera terminado cuando la workload identity configurada puede autenticarse en PostgreSQL y la inicialización en tiempo de ejecución se completa sin el error 28P01.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
azure, docker, kubernetes, postgresql
Área
authentication, backend, cloud, databases
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.