Skip to content

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.

changed in 2.0Before 2.0 an app's `#[Access]` did not reach its OData endpoint, and a set without `#[Read]` could be read by every signed-in partner. Now who may not open the app does not read its data, and `#[Read]` is what opens a set **wider** than its app — a value-help scope, to the role of the picker's `#[Access]` — or narrows it to a role 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.

php
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 ​

RequestResult
reading the gated set itself403, an OData error with the code read_forbidden
$expand into a gated setthe expansion is dropped, the rest answers 200, and a sap-messages header says what was left out
a $batcheach 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.

changed in 2.0It came from the host's `lang/` (`ui5.read_forbidden`).

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_middleware builds that context with BindSdkContextForOData (Configuration).
changed in 2.0**A declared but unsynced `#[Read]` closes the set**, and the log names `ui5:sync`. Before 2.0 it let every read through until the sync had run.

Read, then rows ​

LayerDecidesWhere
Accessmay 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
Readmay the actor read this set, in place of Accessat the OData boundary
Rowswhich rows the actor seesin 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.