Security by design
Attritect puts the security rules of a data screen in one tested engine, so a new page can’t forget them. This page says exactly what the engine enforces, what it doesn’t, and which tests check each guarantee. Attritect is before 1.0: report problems privately (see SECURITY.md).
What the engine enforces
On every engine operation: the HTTP API (/api/crud/...), the Pro admin UI through it, and ICrudService /
ICrudLookups called from your code (permissions there only with EnforcePermissionsInService, see below).
| Guarantee | What it means |
|---|---|
| Deny by default | No permission claim or role, no access: anonymous callers get 401, signed-in callers without the right get 403. Each page and action has its own permission (crud:{page}:{action}). |
| Tenant isolation | With multi-tenancy, lists, gets, lookups, unique checks and reference checks are filtered to the caller’s tenant; another tenant’s row is a 404, so its existence isn’t revealed. |
| The tenant can’t be forged | New rows get the caller’s active tenant, never a value from the request; a row can’t be moved to another tenant. |
| Shared data is protected | Shared pages are read by everyone and written only by the host. |
| Linked rows are checked | A lookup or parent value must exist, be visible to the caller and not be deleted, so a request can’t link to rows the caller can’t see. |
| No over-posting | Only properties marked [Field] are ever written; extra JSON properties are ignored. |
| Restricted fields | [Restricted] fields need their own exact permission (wildcards never grant them); hidden values are removed and can’t be filtered or sorted on. |
| Row rules | [OwnRows], [ScopeBy] and custom row rules limit reads and writes inside a tenant. |
| Pages the API only reads | ApiReadOnly pages refuse writes over HTTP for everyone, the host included. |
| Safe text | [SafeText] refuses angle brackets, and the engine never builds HTML. |
| SQL injection | Every query is translated to SQL with parameters; nothing is concatenated into SQL. |
| Purge needs an exact right | Deleting soft-deleted rows for good needs crud:{page}:purge exactly, never a wildcard. |
What your code must still do
| You are responsible for | Why |
|---|---|
| Authentication | Attritect reads the signed-in user and their claims; it doesn’t sign people in. Use ASP.NET Core Identity, OpenID Connect or similar. The templates’ development sign-in must be replaced. |
| Your own EF queries and SQL | The engine filters by tenant and checks permissions only in its own operations. Your custom queries, ExecuteUpdate / ExecuteDelete and raw SQL see every tenant’s rows: filter and check them yourself. |
Code that calls ICrudService |
By default only the HTTP API checks permissions. Check first, or turn on EnforcePermissionsInService. |
| Background jobs and Blazor circuits | The default user and tenant providers read the HTTP request. Supply them yourself where there’s no request. |
| The host role | The host is allowed everything across tenants. Give it to platform administrators only, and lock the role pages (AddPermissionPages(apiReadOnly: true)) when the host must not reach tenant data. |
| Reviewing AI-written code | The AI kit tells assistants these rules, but review generated code and run the tests before production. |
Details: Security and multi-tenancy.
The tests behind each guarantee
The engine’s test suite runs on every build. The security tests, by file:
| Tests | They check |
|---|---|
TenancyTests |
Another tenant’s rows are invisible and untouchable; a tenant sent by the client is ignored; unique values are per tenant; switching tenants; shared rows and shared pages; 401 / 403; action and wildcard permissions; the host role; the pages list shows only permitted pages |
AccessHttpTests, AccessTests |
Wildcards never grant restricted fields or all rows; hidden fields can’t be filtered or sorted; read-only fields keep their value; own rows, scope and custom row rules on reads and writes |
ApiReadOnlyTests |
Writes are refused for everyone, the host included; the schema reports no writes |
RelationsTests, LookupHelperTests |
Lookups return only rows the caller can see; a link to another tenant’s row is rejected; a parent must be visible and can’t change; preloaded options need view permission |
ServicePermissionTests |
With EnforcePermissionsInService, the service refuses what the caller may not do |
UniqueAcrossFiltersTests |
Unique-for-all checks see rows the app’s own filters hide |
DatabasePermissionTests |
Database roles, exact rights, role-page protection, permissions staying current after role changes |