The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add Firebase auth migration guide
dannykng15db4baead13
diff --git a/apps/reference/docs/guides/migrations/firebase-auth.mdx b/apps/reference/docs/guides/migrations/firebase-auth.mdxindex 66cb82ad5de..b843d55fefd 100644--- a/apps/reference/docs/guides/migrations/firebase-auth.mdx+++ b/apps/reference/docs/guides/migrations/firebase-auth.mdx@@ -5,3 +5,114 @@ description: 'Migrate Firebase auth users to a Supabase project.'sidebar_label: Firebase Auth---+import Tabs from '@theme/Tabs'+import TabItem from '@theme/TabItem'++Supabase provides several [tools](https://github.com/supabase-community/firebase-to-supabase/tree/main/auth) to help migrate auth users from a Firebase project to a Supabase project. There are three parts to the migration process:++- `firestoreusers2json` ([TypeScript](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/firestoreusers2json.ts), [JavaScript](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/firestoreusers2json.js)) exports users from an existing Firebase project to a `.json` file on your local system.+- `import_users` ([TypeScript](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/import_users.ts), [JavaScript](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/import_users.js)) imports users from a saved `.json` file into your Supabase project (inserting those users into the `auth.users` table of your `PostgreSQL` database instance).+- The [middleware](https://github.com/supabase-community/firebase-to-supabase/tree/main/auth/middleware/verify-firebase-pw) server component verifies a user's existing Firebase password and updates that password in your Supabase project the first time a user logs in (currently supports local node development server and hosting with fly.io).++## Generate a Firebase private key {#generate-firebase-private-key}++1. Log in to your [Firebase Console](https://console.firebase.google.com/project) and open your project.+1. Click the gear icon next to **Project Overview** in the sidebar and select **Project Settings**.+1. Click **Service Accounts** and select **Firebase Admin SDK**.+1. Click **Generate new private key**.+1. Rename the downloaded file to `firebase-service.json`.++## Save your Firebase password hash parameters {#save-firebase-hash-parameters}++1. Log in to your [Firebase Console](https://console.firebase.google.com/project) and open your project.+1. Select **Authentication** (Build section) in the sidebar.+1. Select **Users** in the top menu.+1. At the top right of the users list, open the menu (3 dots) and click **Password hash parameters**.+1. Copy and save the parameters for `base64_signer_key`, `base64_salt_separator`, `rounds`, and `mem_cost`.++```bash title="Sample password hash parameters"+hash_config {+ algorithm: SCRYPT,+ base64_signer_key: XXXX/XXX+XXXXXXXXXXXXXXXXX+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==,+ base64_salt_separator: Aa==,+ rounds: 8,+ mem_cost: 14,+}+```++## Set up the `supabase-service.json` file {#set-up-supabase-service-file}++1. Clone the [firebase-to-supabase](https://github.com/supabase-community/firebase-to-supabase) repository:+ ```+ git clone https://github.com/supabase-community/firebase-to-supabase.git+ ```+1. Rename [supabase-service-sample.json](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/supabase-service-sample.json) to `supabase-service.json`.+1. Go to the [Database settings](https://app.supabase.com/project/_/settings/database) for your project in the Supabase Dashboard.+1. Under **Connection Info**, copy the Host string and replace the entry in your `supabase-service.json` file.+1. Enter the password you used when you created your Supabase project in the `password` entry in the `supabase-service.json` file.+1. Save the `supabase-service.json` file.++## Set up the middleware {#set-up-middleware}++You can set up the middleware on a local development server or host with [fly.io](https://fly.io).++<Tabs+ defaultValue="local-server"+ values={[+ {label: 'Local development server', value: 'local-server'},+ {label: 'Host with fly.io', value: 'host-with-fly'},+ ]}>+<TabItem value="local-server">++1. Rename [local.env.sh.sample](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/middleware/verify-firebase-pw/local.env.sh.sample) to `local.env.sh`.+1. Edit the `MEMCOST`, `ROUNDS`, `SALTSEPARATOR`, and `SIGNERKEY` environment variables with your Firebase password hash parameters.+ ```bash title="local.env.sh"+ export PORT=3000+ export MEMCOST=14+ export ROUNDS=8+ export SALTSEPARATOR=Aa==+ export SIGNERKEY=XXXX/XXX+XXXXXXXXXXXXXXXXX+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==+ ```+1. Run `npm i` in `auth/middleware/verify-firebase-pw/` to install dependencies.+1. Run `./local.sh` to start the server on the port listed in `local.env.sh` (defaults to `3000`).++</TabItem>+<TabItem value="host-with-fly">++1. Rename [fly.toml.sample](https://github.com/supabase-community/firebase-to-supabase/blob/main/auth/middleware/verify-firebase-pw/fly.toml.sample) to `fly.toml`.+1. Edit the `[env]` section with your Firebase password hash parameters.+ ```bash title="fly.toml"+ ...+ [env]+ PORT = "8080"+ MEMCOST = 14+ ROUNDS = 8+ SALTSEPARATOR = "Aa=="+ SIGNERKEY = "XXXX/XXX+XXXXXXXXXXXXXXXXX+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=="+ ...+ ```+1. Install the [flyctl](https://fly.io/docs/getting-started/installing-flyctl/) command line utility.+1. [Log in or sign up with fly.io](https://fly.io/docs/getting-started/log-in-to-fly/).+1. Launch the Fly app with `flyctl launch`.+1. Deploy the Fly app with `flyctl deploy`.++See [Build, Deploy and Run a Node Application](https://fly.io/docs/getting-started/node/) for more details.++</TabItem>+</Tabs>++## Command line options++### Dump Firestore users to a JSON file {#dump-firestore-users}++`node firestoreusers2json.js [<filename.json>] [<batch_size>]`++- `filename.json`: (optional) output filename (defaults to `./users.json`)+- `batchSize`: (optional) number of users to fetch in each batch (defaults to 100)++### Import JSON users file to Supabase Auth (PostgreSQL: auth.users) {#import-json-users-file}++`node import_users.js <path_to_json_file> [<batch_size>]`++- `path_to_json_file`: full local path and filename of .json input file (of users)+- `batch_size`: (optional) number of users to process in a batch (defaults to 100)