firebase-auth-ext
This project contains a simple authentication demo for the Firebase by a Web3 wallet. It uses the Authenticate with Moralis Auth extension for the Firebase.
Required Google Cloud services:
- Firebase Hosting
- Firebase Authentication
- Firebase Cloud Functions (only in the Blaze plan, check the pricing).
- Secret Manager (check the pricing)
🚀 How to Start​
- Clone this repo.
- Install Firebase CLI globally:
npm install -g firebase-tools
- Login to your account:
firebase login
- Get list of your projects:
firebase projects:list
. If this list is empty you should add a new project. You can do it by the Firebase Console. - Set your project ID:
firebase use <PROJECT_ID>
- Generate a certificate for the Service Account. You will need it in the next step.
- Convert the certificate to extension variables by this online converter. You will use these variables in the next step.
- Install the Authenticate with Moralis Web3 extension:
firebase ext:install moralis/moralis-auth
. - Copy
hosting/.env.example
tohosting/.env
and set all variables. - Build the functions project:
cd functions
yarn install
yarn run build
- Build the hosting project:
cd hosting
yarn install
yarn run build
- Activate the
Authentication
feature in the Firebase Console. Go to the Firebase Console > Your Project > Build > Authentication and click the Get Started button.
🔌 Run Locally​
- Install Java on your computer. Functions Emulator requires Java.
- Run emulators:
firebase emulators:start
- Open
http://localhost:5555/
in your browser.
🔥 Deploy to Production​
- Deploy:
firebase deploy
- If you have any problem with the CORS on the production, probably you should allow unauthenticated HTTP function invocation. To allow unauthenticated invocation you must specify this at or after deployment. Here you can read more about it.