--- 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. | 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. ## 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). 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. ## 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.