Azure / Azure/data-api-builder
[Feature] Add support for database policies with relations
- Vorherrschende Sprache
- C#
- Sterne
- 1.5k
- Forks
- 370
- Ø Merge
- 3 T. 22 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
DAB currently offers support for simple Odata expressions when defining “RLS” policies for an entity as explained in the [public doc](https://learn.microsoft.com/en-us/azure/data-api-builder/reference-configuration?tabs=http#database).
```
{
"entities": {
"User": {
"source": {
"object": "dbo.Users",
"type": "table"
},
"permissions": [
{
"role": "selfReader",
"actions": [
{
"action": "read",
"policy": {
"database": "@claims.userId eq @item.Id"
}
}
]
}
]
}
}
}
```
This instructs DAB to return rows from User table only for which Id value matches with the userId claim. The expression supports filtering on columns on the same entity only.
In many cases, customers keep user details or mapping details on a separate table altogether. Consider the following database schema.
Books
-Id
-Title
-SellerId (relationship with Sellers on its id)
Sellers
-id
-email
Let’s say we want to return Book rows only if its seller email is the same as caller’s email.
To support his behavior, we would need support for enhanced Odata expressions such as
`@item.sellerId/all(s: s/email eq @claims.upn)`
OR
`@item.sellerId/any(s: s/email eq @claims.upn)`
Beitragsleitfaden
Rechercherichtung
Beginne mit der verlinkten Dokumentation zu Datenbankrichtlinien und der aktuellen Implementierung einfacher OData-RLS-Ausdrücke. Verfolge, wie Entitätsbeziehungen und Claims dargestellt werden, und ermittle anschließend, wie relationale Ausdrücke wie any/all ausgewertet werden sollen. Als abgeschlossen gilt die Aufgabe, wenn Richtlinien eine Entität anhand einer verknüpften Tabelle unter Verwendung des angeforderten Claims des Aufrufers filtern können und eine Abdeckung für das Beispiel mit Books und Sellers vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- api, authorization, databases
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100