Azure / Azure/data-api-builder
[Bug]: REST unexpected authorization error when excluding primary key and using orderby
- 主要言語
- C#
- スター
- 1.5k
- フォーク
- 370
- 平均マージ
- 3日 22時間
- マージ済み PR(30日)
- 9
説明
### What happened?
If a primary key is excluded through the `actions.fields.exclude` property an authorization error occurs when the `orderby` clause is used in the request, even if the field used in the `orderby` is authorized.
Configuration file: In this case `id` is a primary key
```
"Book": {
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "create"
},
{
"action": "read",
"fields": {
"include": [ "*" ],
"exclude": [ "id" ]
},
"policy": {
"database": "id gt 2"
}
}
}
```
REST request used: ` https://localhost:5001/api/Book?$orderby=title asc`
### Version
1.6.68
### What database are you using?
Azure SQL
### What hosting model are you using?
_No response_
### Which API approach are you accessing DAB through?
REST
### Relevant log output
```Text
fail: Azure.DataApiBuilder.Service.Controllers.RestController[0]
71916690-677b-4638-a837-b2e7eaa8fee6 Error handling REST request.
Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: Authorization Failure: Access Not Allowed.
at Azure.DataApiBuilder.Core.Services.RestService.AuthorizationCheckForRequirementAsync(Object resource, IAuthorizationRequirement requirement) in C:\Users\rcernaserna\DAB\data-api-builder\src\Core\Services\RestService.cs:line 508
at Azure.DataApiBuilder.Core.Services.RestService.ExecuteAsync(String entityName, EntityActionOperation operationType, String primaryKeyRoute) in C:\Users\rcernaserna\DAB\data-api-builder\src\Core\Services\RestService.cs:line 189
at Azure.DataApiBuilder.Service.Controllers.RestController.HandleOperation(String route, EntityActionOperation operationType) in C:\Users\rcernaserna\DAB\data-api-builder\src\Service\Controllers\RestController.cs:line 239
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
コントリビューションガイド
調査の方向性
src/Core/Services/RestService.cs の 508 行目付近にある認可チェックから始め、次に src/Service/Controllers/RestController.cs の 239 行目を通るリクエストフローを追跡します。actions.fields.exclude を id に設定し、orderby=title asc とした REST リクエストを再現します。認可された orderby リクエストが認可エラーなしで成功し、主キーが引き続き除外されたままになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- azure, csharp, sql
- 領域
- api, authorization, databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100