Files
supabase/apps/docs/content/guides/auth/architecture.mdx
Miranda Limonczenko b66bedd1c9 docs(guides): rework five explainer pages to the explainer template (#53755)
## Problem

Five concept pages are close to the explainer template from #53751 but
don't follow it. They have no value statement and no Related resources,
and they have style gaps such as missing descriptions, topic-name alt
text, and a diagram with no accessibility title or description.

Part of DOCS-1617. A second batch of five pages is in #53757.

## Solution

The PR is one squashed commit. It covers a style pass, the restructure
to the template, critic-pass fixes, tables and lists, the opener change,
and content moved in from other pages.

### Structure

| Page | Change |
| --- | --- |
| `auth/architecture` | Value statement, a `## Layers` table from the
numbered list, Related resources |
| `storage/cdn/fundamentals` | Value statement, `## Example` renamed to
`## How caching works`, Related resources |
| `storage/schema/design` | Retitled `Storage schema`, value statement,
`## Tables` heading, the tables paragraph as a table, Related resources
|
| `storage/security/ownership` | Retitled `Storage ownership` with the
sidebar label `Ownership`, value statement, the deprecated `owner` note
moved into body text, Related resources |
| `auth/identities` | Retitled `Auth identities`, value statement,
Related resources |

- **Linked headings**: headings that other pages link to keep their
text: `#client-layer`, `#auth-service`, `#postgres`,
`#public-vs-private-buckets`, and `#the-user-identity-object`.
- **Openers and tables**: only the value statement and a cross-reference
come before the first heading, and each concept opener moves into the
first H2, per the template change in #53751. Prose comparisons and
parallel facts become tables and lists. On Storage CDN, the cache steps
are a numbered list, and a library analogy follows them.
- **Moved content**: each explainer now owns its concept, and the how-to
that held it links back. Nothing is newly written; every added fact
comes from an existing page:
- Identities: `## How Auth links identities` and `## Limits`, moved from
the Automatic linking section and SAML note in [Identity
linking](/docs/guides/auth/auth-identity-linking), which now links back.
- Storage ownership: who owns a copied or moved object, from [Copy
objects](/docs/guides/storage/management/copy-move-objects), which links
back.
- Auth architecture: `## Limits`, the Auth server's single region, from
[JWTs](/docs/guides/auth/jwts#verifying-a-jwt-from-supabase), which now
keeps only its advice and links back.
- Storage CDN: the extra statuses that count as hits, from [Cache
metrics](/docs/guides/storage/cdn/metrics), which links back.
- **Facts**: unchanged. The value statements, Related resources, and the
CDN analogy are the only new text. Tables, lists, and moved content
restate facts already in the docs.

### Style
- **Descriptions**: add or rewrite one per page, 150 to 160 characters.
- **Alt text**: rewrite against the images. The Auth architecture
diagram now names each route and service, and the two CDN images
describe the cache miss and cache hit.
- **Diagram**: add `accTitle` and `accDescr` to the Storage schema
diagram.
- **Admonitions**: lead with their impact, and cut one that restated the
body text on Auth architecture.
- **Terms**: `WORD_LIST.md` passes for _we_, _will_, _since_, _auto-_,
_ID_, numbers, and spelled-out RLS. External links name their
destination.
- **Subtitles**: cut two that repeated the title or description.

The critic-pass fixes come from a clean-context critic pass against the
style guide.

Facts are unchanged. Skipped on purpose:

- The CDN page's two PNG sequence diagrams aren't converted to Mermaid,
because that's new content.
- `Public vs private buckets` keeps `vs`, because other pages link to
that heading.

### Structure numbers

These numbers are from before the opener and table changes.

| Page | Chars before → after | Headings | Generic headings |
Description chars |
| --- | --- | --- | --- | --- |
| `auth/architecture` | 3,437 → 4,839 | 3 → 5 | 0 → 0 | 0 → 159 |
| `storage/cdn/fundamentals` | 2,617 → 3,632 | 2 → 3 | 1 → 0 | 53 → 152
|
| `storage/schema/design` | 2,819 → 3,875 | 1 → 3 | 0 → 0 | 30 → 154 |
| `storage/security/ownership` | 1,628 → 2,006 | 1 → 2 | 0 → 0 | 71 →
155 |
| `auth/identities` | 3,315 → 4,087 | 1 → 2 | 0 → 0 | 0 → 159 |

Characters grow mostly from descriptions, longer alt text, table
padding, and Related resources. Search top-k isn't recorded, because
there's no fixed query set yet.

### How the template did

- **Fit without changes**: the value statement with a how-to link,
Related resources, the `How <concept> works` Process slot, and the
diagram accessibility rule. The rule caught a real gap on Storage
schema.
- **Fit after a fix in #53751**: the concept heading, one H2 per part,
linked headings in a slot, principles, and the repeated how-to link. See
the learnings in #53751.
- **Still loose**: `auth/architecture` has no concept paragraph of its
own, because the layers are the concept. `storage/security/ownership`
has an `## Access control` section that fits no slot, which is a
principle plus one SQL example.

### Preview

| Page | Live | Preview |
| --- | --- | --- |
| Auth architecture |
[Live](https://supabase.com/docs/guides/auth/architecture) |
[Preview](https://docs-git-docs-explainer-rework-supabase.vercel.app/docs/guides/auth/architecture)
|
| Storage CDN |
[Live](https://supabase.com/docs/guides/storage/cdn/fundamentals) |
[Preview](https://docs-git-docs-explainer-rework-supabase.vercel.app/docs/guides/storage/cdn/fundamentals)
|
| Storage schema |
[Live](https://supabase.com/docs/guides/storage/schema/design) |
[Preview](https://docs-git-docs-explainer-rework-supabase.vercel.app/docs/guides/storage/schema/design)
|
| Storage ownership |
[Live](https://supabase.com/docs/guides/storage/security/ownership) |
[Preview](https://docs-git-docs-explainer-rework-supabase.vercel.app/docs/guides/storage/security/ownership)
|
| Identities | [Live](https://supabase.com/docs/guides/auth/identities)
|
[Preview](https://docs-git-docs-explainer-rework-supabase.vercel.app/docs/guides/auth/identities)
|

## Review instructions

1. Open each page's live and preview links from the Preview table side
by side.
2. Check that each page opens with a value statement and ends with
Related resources.
3. Open `/docs/guides/auth/architecture#client-layer` and
`/docs/guides/storage/cdn/fundamentals#public-vs-private-buckets` on the
preview, and check that each jumps to its heading.
4. On Auth architecture and Storage CDN, compare the new alt text with
the images in `apps/docs/public/img`.
5. On Storage schema, check that the diagram renders and that the tables
table matches it.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-23 16:18:11 -08:00

93 lines
5.0 KiB
Plaintext

---
title: 'Auth architecture'
description: 'Learn how Supabase Auth is built from the client layer, the API gateway, the Auth service, and Postgres, and what each of these four layers is responsible for.'
---
Knowing which layer of Supabase Auth does what tells you where to look when you sign in users, issue tokens, or store user data. For how to sign users in, see [Password-based Auth](/docs/guides/auth/passwords).
## Layers
Supabase Auth sits between your app and your database, in four layers:
| Layer | What it does |
| ------------------------------ | --------------------------------------------------------------------------------------------- |
| [Client layer](#client-layer) | Calls the Auth API from your app, through a Supabase client SDK or your own HTTP requests. |
| Envoy API gateway | Routes each request to the right service. Shared between all Supabase products. |
| [Auth service](#auth-service) | Issues and refreshes JWTs, and talks to external sign-in providers. Formerly known as GoTrue. |
| [Postgres database](#postgres) | Stores users and other Auth data in the `auth` schema. Shared between all Supabase products. |
<Image
alt="Diagram of the Supabase architecture. The Envoy API gateway routes each request by path to one of seven services: /auth to GoTrue, /rest to PostgREST, /realtime to Realtime, /storage to Storage, /pg to pg-meta, /functions to Functions, and /graphql to pg_graphql. All seven services connect to a single Postgres instance."
src={{
dark: '/docs/img/supabase-architecture.svg',
light: '/docs/img/supabase-architecture--light.svg',
}}
width={1600}
height={767}
/>
## Client layer
The client layer runs in your app. Your app can run in many places, including:
- Your frontend browser code
- Your backend server code
- Your native application
The client layer provides the functions that you use to sign in and manage users. We recommend using the Supabase client SDKs, which handle:
- Configuration and authentication of HTTP calls to the Supabase Auth backend
- Persistence, refresh, and removal of Auth Tokens in your app's storage medium
- Integration with other Supabase products
At its core, this layer makes HTTP calls, so you can write your own client layer.
For more information, see the client SDK references:
- [JavaScript](/docs/reference/javascript/introduction)
- [Flutter](/docs/reference/dart/introduction)
- [Swift](/docs/reference/swift/introduction)
- [Python](/docs/reference/python/introduction)
- [C#](/docs/reference/csharp/introduction)
- [Kotlin](/docs/reference/kotlin/introduction)
## Auth service
The Auth service is the Auth API server. It's responsible for:
- Validating, issuing, and refreshing JWTs
- Serving as the intermediary between your app and Auth information in the database
- Communicating with external providers for social sign-in and SSO
When you deploy a new Supabase project, Supabase deploys an instance of this server alongside your database. It also adds the required Auth schema to your database.
Supabase writes and maintains the Auth service as a fork of the GoTrue project, originally created by Netlify. Its source code is in the [`supabase/auth` repository](https://github.com/supabase/auth) on GitHub.
## Postgres
Supabase Auth uses the `auth` schema in your Postgres database to store user tables and other information. For security, this schema is not exposed on the autogenerated API.
To work with Auth data in your own tables:
- Connect it to your own objects with [database triggers](/docs/guides/database/postgres/triggers) and foreign keys, described in the Postgres documentation on [foreign keys](https://www.postgresql.org/docs/current/tutorial-fk.html).
- Protect any views you create for Auth data by enabling [Row Level Security](/docs/guides/database/postgres/row-level-security) (RLS) or by revoking grants, described in the Postgres documentation on [`REVOKE`](https://www.postgresql.org/docs/current/sql-revoke.html).
<Admonition type="danger">
Views you create for Auth data can bypass RLS, depending on how you create them:
- In Postgres 15 and later, views created with `security_invoker` inherit the RLS policies of the underlying tables.
- Views in earlier versions, or those created without `security_invoker`, inherit the permissions of the owner, who can bypass RLS policies.
</Admonition>
## Limits
The Auth server runs only in your project's region and isn't globally distributed. Checking a JWT with the Auth server from far away, such as from an edge function, can be slow. For other ways to verify a JWT, see [Verifying a JWT from Supabase](/docs/guides/auth/jwts#verifying-a-jwt-from-supabase).
## Related resources
- [Password-based Auth](/docs/guides/auth/passwords): sign users in through the client layer.
- [JWTs](/docs/guides/auth/jwts): the tokens the Auth service issues and refreshes.
- [Users](/docs/guides/auth/users): the user records that Auth stores in the `auth` schema.