@hounddesk/plugin-firebase-authz
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@hounddesk/plugin-firebase-authz

Firebase authorization plugin for Hapi, use this plugin for validating the JWT generated by Firebase.

How it works ?

  1. Verify the token using the firebase admin SDK
  2. Verify that the decoded token contains the proper claims

Usage

import Hapi from '@hapi/hapi';
import { ServiceAccount } from 'firebase-admin';
import pluginFirebaseAuthz from '@hounddesk/plugin-firebase-authz';

// Initialize your firebase application using the sdk
const firebaseApp = admin.initializeApp(...);

// Register the plugin
await server.register({
    plugin: pluginFirebaseAuthz,
    options: {
      serviceAccount: firebaseApp,
      logger: console,
      userClaims: ['admin'], // optional
      schemeName: 'firebase', // optional, by default will use firebase
    },
  });
  // Register the authorization strategy
  server.auth.strategy('firebase', 'firebase');

Readme

Keywords

Package Sidebar

Install

npm i @hounddesk/plugin-firebase-authz

Weekly Downloads

7

Version

1.1.2

License

MIT

Unpacked Size

10.1 kB

Total Files

12

Last publish

Collaborators

  • degrammer