View a markdown version of this page

Auth - AWS Amplify

Auth

Auth gives your app authentication, authorization, and user management, built into your Amplify backend. It runs on managed Better Auth, an open-source authentication framework that AWS Amplify operates and updates.

Your users can sign up and sign in with email and password, or with an account that they already have at a social provider such as Google, Apple, GitHub, or Microsoft. You can also connect your own OAuth 2.0 or OpenID Connect provider, such as your company’s identity provider, or an existing Amazon Cognito user pool. To give users sign-in screens without building them, turn on the managed sign-in page.

Auth provides the following:

  • Authentication – Checks that a user is who they say they are. Auth signs your users up and in, keeps them signed in, and signs them out.

  • Authorization – Checks what a signed-in user can read and change. You write the access rules as grants and row-level security (RLS) policies in your database. The database checks them on every request.

How auth works with your backend

Amplify connects auth to your database and data API in the following ways:

  • Users are stored in your database – Each backend branch has its own users, so preview and production have different users. Your own tables can refer to a user, for example with an owner column on each row.

  • Data API requests run as the signed-in user – After a user signs in, the client SDK adds the user’s token to each data API request. The database runs the request as that user. The data API returns only the rows that your RLS policies allow, on the tables that you granted to the authenticated role.

  • Public access for visitors – A visitor who isn’t signed in can reach only the tables that you granted to the anon role, and only the rows that your RLS policies allow for it.

  • Privileged access for your server code – Server code that needs to read or change every row, such as a job that processes all orders, signs its requests with AWS credentials. Those requests get full access to your data through the data API. Only code that runs with the required AWS Identity and Access Management (IAM) permissions can make them. You don’t keep a secret key in your code or your app.

  • Auth settings in your repository – You keep your auth settings in amplify.jsonc in your repository. The local backend uses the root backend.auth block. Each deployment applies the root block, or the environment’s own env.<name>.backend.auth block if it has one. Amplify sets the database that auth uses, its signing secret, password hashing, and token signing. You can’t change them. Your own provider secrets, such as OAuth client secrets and an SMTP password, go in as ${env:NAME} references.

Get started

To add sign-in to your app and protect your data, read these pages in order:

Sign-in methods

Your users can sign in using any of the following methods. Email and password is on by default, and you turn on each of the others in your auth settings. An auth block that you write replaces the defaults, so keep "emailAndPassword": { "enabled": true } in it to keep password sign-in.

  • Email and password – Users sign up with an email address and a password. For more information, see Email and password.

  • Social providers – Users sign in with an account at Apple, Discord, Facebook, GitHub, Google, LinkedIn, Microsoft, Slack, Spotify, and X (Twitter). For more information, see Social sign-in and OAuth.

  • Passkeys – Users sign in with a passkey on their device, and confirm it with their device’s PIN, fingerprint, or face. For more information, see Passkeys.

  • Two-step verification – Users enter a code from an authenticator app, an emailed code or a backup code after their first sign-in step. For more information, see Two-step verification.

  • Email links and email codes – Users sign in without a password. Auth emails them a sign-in link, or a one-time code that they type into your app. For more information, see Passwordless sign-in.

  • Amazon Cognito – Users sign in with their account in an existing Cognito user pool that you connect as a provider. For more information, see Social sign-in and OAuth.

  • Your own OAuth 2.0 or OpenID Connect provider – Users sign in with an account at a provider that you connect, such as your company’s identity provider. For more information, see Social sign-in and OAuth.

Managed sign-in page

Your backend can serve its own sign-in page. Your app redirects users to the page, and they come back to your app signed in. The managed sign-in page provides the following:

  • Sign-up, sign-in, and password reset – A page for sign-up, sign-in, asking for a password reset, and setting a new password, served under <backend URL>/auth/ui/.

  • The sign-in methods that you turn on – Including a "Continue with" button for each social provider.

  • Your app’s name – The browser tab and the sign-in and sign-up headings show your app’s name.

The managed sign-in page is off by default, and you turn it on in your auth settings. To match your app’s colors, logo, and layout, build your own screens with the client SDK. Your screens can offer the same sign-in methods. For more information, see Managed sign-in page.

Topics

Topic What it covers

User sessions

How users stay signed in, sessions and tokens, and signing out

Server-side rendering

The signed-in user in server code

Email and password

Sign-up, email verification, sign-in and password reset

Social sign-in and OAuth

Social providers, Amazon Cognito, your own OAuth providers, and account linking

Passwordless sign-in

Sign-in with an emailed link or an emailed one-time code

Passkeys

Sign-in with a passkey on the user’s device

Two-step verification

A second sign-in step with an authenticator app, an emailed code or a backup code

Managed sign-in page

The sign-in, sign-up, and password reset screens that your backend serves

Auth configuration

Every auth setting, trusted origins and auth secrets

Auth emails

Verification and password reset emails, templates, and your own email server

Manage users

Create, list, change and delete users, and connect your tables to them