The Read Gate
OData in LaravelUi5 is read-only: writing goes through actions. Whether an actor may read an entity set at all is decided by two gates, and exactly one of them applies to each set:
- A set with its own
#[Read]is read by that Read ability alone. - Every other set is read by whoever may open the app: the app's
#[Access]. An app without#[Access]is open, and so are its sets.
Which rows they then see is a separate question, answered by scoping.
since 3.1 A library that serves data is gatedthe same way: its #[Access] stands where the app's does. A library carries none as a rule — its data is for every app that uses it —, so its sets are read by every signed-in partner, unless a set has a #[Read] of its own.
Declaring it
Put #[Read] on the class the entity set is built from: a custom entity set, or the Eloquent model behind a discoverModel set.
use LaravelUi5\Sdk\Security\Attributes\Read;
#[Read('readInvoices', AcmeRole::Accounting, note: 'Read the invoice list.')]
final class InvoicesSet extends AbstractEntitySet
{
// …
}It takes the same three arguments as #[Access] and #[Act]: the ability, its role (declared with #[Role] on the module) and a note. The ability belongs to the app that exposes the set, and the set's OData name is its key. Run ui5:sync after adding it, then grant the role (Permission Levels).
What a denied read gets
| Request | Result |
|---|---|
| reading the gated set itself | 403, an OData error with the code read_forbidden |
$expand into a gated set | the expansion is dropped, the rest answers 200, and a sap-messages header says what was left out |
a $batch | each item is checked on its own |
The message reads "You are not authorized to read …" in the request's language — the SDK's text sdk.read.forbidden from Core's bundle.
When it lets a read through
- The set has no
#[Read]and the actor may open the app — or the app carries no#[Access]. - The set has its own
#[Read]and the actor holds it, whether or not they may open the app. - The request has no SDK context. Your
odata_middlewarebuilds that context withBindSdkContextForOData(Configuration).
Read, then rows
| Layer | Decides | Where |
|---|---|---|
| Access | may the actor open the app or value help — and read the app's sets that carry no #[Read] | when it is opened, and at the OData boundary |
| Read | may the actor read this set, in place of Access | at the OData boundary |
| Rows | which rows the actor sees | in the set's query (Scoped Entity Sets) |
A value help carries #[Access] for opening it. The scopes it offers point at the Read ability of the set behind them.