Azure / Azure/data-api-builder

Postgresql database connection with Workload Identity in an AKS deployment

Đang mở
#2,271 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
cri enhancement
Ngôn ngữ chính
C#
Star
1.5k
Fork
372
Merge trung bình
3 ngày 22 giờ
Pull request đã merge (30 ngày)
9

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với việc xử lý kết nối và danh tính PostgreSQL được tham chiếu trong src/Core/Services/MetadataProviders/SqlMetadataProvider.cs, đặc biệt là các vị trí trong stack trace quanh dòng 100 và 1116. Tái hiện thiết lập AKS bằng dab-config.json và biến môi trường DATABASE_CONNECTION. Được xem là hoàn tất khi workload identity đã cấu hình có thể xác thực với PostgreSQL và quá trình khởi tạo runtime thành công mà không gặp lỗi 28P01.

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, docker, kubernetes, postgresql
Lĩnh vực
authentication, backend, cloud, databases
Loại issue
Lỗi
Độ 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
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.