본문으로 건너뛰기
아우라베이스 로고
아우라베이스

Project isolation

Where your tables live, what else shares the server with them, and what stops one project from reading another, layer by layer.

설명7분 읽기레벨 중급

이 페이지는 아직 귀하의 언어로 제공되지 않습니다. 영어로 표시됩니다.

Mental model#

A project is a PostgreSQL database, not a schema in a shared database. On the Free and Pro plans that database sits on a PostgreSQL cluster that belongs to your organization: the other projects of the same organization have their own databases on it, and no other organization does. On Team and Enterprise, a project gets a cluster of its own. Shared and dedicated clusters compares the two.

organization (Free or Pro)
└── PostgreSQL cluster of the organization
    ├── database project_<project-a-id>   ← project A
    ├── database project_<project-b-id>   ← project B
    └── …

organization (Team or Enterprise)
└── PostgreSQL cluster of the project     ← one project, its own instances

Inside the database#

The database of a project holds several schemas. Yours has the same name as the database; the others belong to the platform, inside the same database.

SchemaContent
project_<id>Your tables, views, functions and policies. Unqualified names resolve here.
project_<id>_authUsers, sessions, identities and settings of Auth
project_<id>_storageBuckets, object metadata and the storage audit log
project_<id>_platformSettings of functions, notifications, realtime and AI
authThe helpers auth.uid(), auth.role(), auth.tenant(), auth.jwt()…
publicThe installed extensions (vector, pgcrypto…)

<id> is the project id with underscores instead of dashes: project 41fd6f07-3acf-48cf-9eb5-d665ce99a849 uses the database and the schema project_41fd6f07_3acf_48cf_9eb5_d665ce99a849.

The platform schemas are part of your project, not hidden from it. Who reaches them, and through which door:

DoorYour schemaPlatform schemas of your project
SDK and REST (any key)YesNo: the REST API serves only your schema; a table of another schema answers TABLE_NOT_FOUND
aura db raw, db.sql(), Studio SQL editor (service_role key)YesYes: the SQL check accepts the schemas of your own project, and the administrator role owns their tables and bypasses row level security. select count(*) from project_<id>_auth.users counts your users.
aura db raw --as anon or --as authenticatedYes, under your policies_auth and _storage: the public roles hold privileges, but the tables of _auth have row level security forced and no policy, so no row comes back; storage_buckets and storage_objects carry the policies of the Storage API. _platform: no privilege, except on realtime_messages (row level security forced, no policy).
Direct connection, as the proj_ roleYes, under your policiesSame as the line above: project_<id>_auth.users returns no row, project_<id>_platform answers permission denied; the tables without row level security listed below are readable.
Direct connection after SET LOCAL ROLE tenant_<id>_adminYes, every rowYes, every row: the proj_ role may switch to the administrator role, which owns the tables and bypasses row level security, exactly like the service_role key on aura db raw.

Two consequences:

  • Treat the service_role key and the password of the direct connection as admin credentials on Auth and Storage data too. With either, SQL reads and changes users (password hashes and MFA settings included), sessions and object metadata directly, bypassing the checks of the Auth and Storage APIs.
  • A view or function you create can expose a platform table. A few tables have no row level security and are readable by aura_anon and aura_authenticated: the migration ledgers (_sqlx_migrations) of _auth and _storage, storage_audit_log and storage_derivatives. The REST API does not serve them, but a view in your schema that selects from them would, to the anon key. Keep views and functions on your own tables.

Check what each role reads in the users table of your project:

AUTH_SCHEMA="project_${PROJECT_ID//-/_}_auth"
aura db raw "select count(*) >= 0 as readable from $AUTH_SCHEMA.users"
aura db raw --as anon "select count(*) as visible_users from $AUTH_SCHEMA.users"
aura db raw --as authenticated --user 00000000-0000-4000-8000-0000000000a1 "select count(*) as visible_users from $AUTH_SCHEMA.users"
  readable
  ────────
  true

  ℹ 1 row(s).
  ℹ Executed as anon.
  visible_users
  ─────────────
  0

  ℹ 1 row(s).
  ℹ Executed as authenticated (00000000-0000-4000-8000-0000000000a1).
  visible_users
  ─────────────
  0

  ℹ 1 row(s).

The same table through the REST API, even with the service_role key:

curl -s "$AURABASE_URL/v1/db/$PROJECT_ID/users?select=id" -H "apikey: $AURABASE_SERVICE_ROLE_KEY" \
  | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).error.code'
TABLE_NOT_FOUND

What keeps projects apart#

No single mechanism carries the isolation. Each path into the database goes through several of these layers:

LayerWhat it doesApplies to
GatewayResolves the project from the host and the path, and checks that the API key belongs to that project.SDK, REST, aura db raw
Signed token per projectThe gateway signs the token it forwards to the project's PostgREST with a secret derived from the project id.SDK, REST
PostgreSQL rolesRequests run as aura_anon, aura_authenticated or an administrator role created for the project alone (tenant_<id>_admin). See Roles, keys and RLS bypass.Every path
Row level securityOn by default for tables created through Aurabase; filters rows by auth.uid() and the policies you write.SDK, REST, direct connection
SQL check of /rawRefuses references to another project's schema, to the system catalogs and to the platform's console schema, before the SQL reaches PostgreSQL.aura db raw, the Studio SQL editor, db.sql()
Router of the direct connectionReads the role name, picks the database of that role's project and forces it; refuses a role presented on another project's host.psql, ORMs
Host rules of the clusterA direct-connection role may only open the database of its own project, whatever the router does.psql, ORMs

See it from your project#

The database and the schema of the project share one name, and a query that names another project's schema is refused before it runs:

select current_database() = current_schema() as same_name,
       current_schema() like 'project\_%' as project_schema
  project_schema │ same_name
  ───────────────┼──────────
  true           │ true

  ℹ 1 row(s).
import { createClient } from '@aurabase/aurabase-js'

const admin = createClient(process.env.AURABASE_URL!, process.env.AURABASE_SERVICE_ROLE_KEY!)
const { error } = await admin.db.sql('select * from project_00000000_0000_0000_0000_000000000000.todos')
console.log(error?.status, error?.message)
400 Invalid request: Cross-schema reference not allowed: 'project_00000000_0000_0000_0000_000000000000' — only the current project's schema is accessible

Trade-offs#

  • Projects of one organization share a server. On Free and Pro, CPU, memory, disk and the max_connections budget of the cluster are shared by the projects of the organization. A heavy query in one project slows the others down; it never reaches another organization.
  • Some roles are shared within a cluster. aura_anon, aura_authenticated and aura_service_role exist once per cluster. What isolates projects is the database each request is routed to and the roles created per project, not those three names.
  • No catalog access through /raw. information_schema, pg_catalog and the system views are refused on that path because a cluster-wide view could list other projects. Use the aura db commands (table list, inspect, slow-queries) or the direct connection, where PostgreSQL itself limits what your role sees.
  • No extension, schema or role of your own. A project cannot run CREATE EXTENSION, CREATE SCHEMA or CREATE ROLE; How extensions are installed explains why.
  • Isolation of the dedicated cluster. The layout above is what a project on the cluster of its organization gets. The dedicated cluster of Team and Enterprise is described from the provisioning code and was not replayed for this page.
@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ 문제 신고