Expand description
Built-in resources.
organization, membership, user, api_key and oauth_connection exist
in every app. Together they make apps multitenant out of the box: users join
organisations through memberships (which also carry their role within that
organisation), and every other resource is isolated per organisation by
default.
Drop a models/<name>.toml with the same name to replace a built-in and
add fields or tweak permissions while keeping the machinery working.
Constants§
- API_
KEY_ TOML - Default
api_keyresource (global). A valid key authenticates as its owner. - MEMBERSHIP_
ROLE_ TOML - A single role held by a membership.
- MEMBERSHIP_
TOML - A user’s membership in an organisation, carrying their role there. The
join table behind the N:N between
userandorganization. - OAUTH_
TOML - Default
oauth_connectionresource (global) linking a user to a provider. - ORGANIZATION_
TOML - The
organization— the tenant.globalbecause its rows are the organisations; membership (not anorganization_id) decides who sees them. - USER_
TOML - The default
user: global (users are shared across organisations) with email + password auth. Extend viamodels/users.toml.
Functions§
- builtins
- The name → embedded-TOML table of built-ins, in dependency order so foreign keys resolve (organization and user before membership/api_key/oauth).
- parse_
builtin - Parse one built-in by its embedded TOML. Panics on a malformed built-in — that would be a bug in this crate, caught by the test below.