@hounddesk/plugin-firebase-authz
v1.1.2
Published
Hapi firebase plugin for Authorization validation
Downloads
3
Readme
@hounddesk/plugin-firebase-authz
Firebase authorization plugin for Hapi, use this plugin for validating the JWT generated by Firebase.
How it works ?
- Verify the token using the firebase admin SDK
- 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');