0.9.1 • Published 1 year ago

@chalermpong/strapi-firebase-auth-strategy v0.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

strapi-firebase-auth-strategy

Use Firebase Auth ID Token with your strapi backend

Installation

  1. Install the plugin
npm i --save @chalermpong/strapi-firebase-auth-strategy
  1. In Firebase console, generate a private key file for Firebase Service Account https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments

  2. Add the following code in your config/plugins.ts file.

import serviceAccount from 'path/to/firebase-adminsdk-fbsvc-xxx.json'

export default ({env}) => ({
  'firebase-auth-strategy': {
    enabled: true,
    config: {
      serviceAccount: serviceAccount,
    },
  },
})

How to use

  1. Just authenticate your user with Firebase.
  2. Get ID token of your user, then add Authorization: Bearer [Firebase ID Token] to your http request to strapi.
  3. Every user needs to call registerFirebase api first to create a new user-permission.user record. After that he can start using other api on your backend.