access/v1

Contracts speak only scopes and owners. This contract is the one place auth collections and roles turn into grants: an ordered list of rows, each an auth collection (or *), an optional PocketBase filter on the caller's own record, and the grants it gives (billing, billing:read@all). A caller holds the union of every enabled row it matches.

Three layers: extension defaults (AddDefault), pocketone.yaml, and Settings. A superuser may switch off any default or yaml row. The superusers row (SuperuserRow, *@all) is fixed.

A Go-only service (access.go), one provider per app: Access.

Use

accessv1.AddDefault(app, "billing", accessv1.Default{Name: "owners", Who: "users", Grant: []string{"billing"}})

p, _ := accessv1.Contract.Of(app)
rows, _ := p.Rows(ctx)              // every row, in layer order, switched-off ones with Enabled false
gs, _ := extkit.GrantsOf(ctx, app, a) // what a caller holds, narrowed to its token's scopes

Provide

Implement Policy: Grants(ctx, auth) (what the policy gives a non-superuser principal, before a token narrows it) and Rows(ctx). Providing the contract makes the provider the gate's grant source.

Extensions

Extension
access provides (default)

License

MIT