passport-firebase-jwt
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "passport-firebase-jwt", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Passport authentication strategy for Firebase JWT token", | ||
@@ -33,3 +33,4 @@ "main": "./lib", | ||
"mocha": "^6.1.4", | ||
"sinon": "^1.0.0" | ||
"sinon": "^1.0.0", | ||
"typescript": "^4.3.2" | ||
}, | ||
@@ -36,0 +37,0 @@ "dependencies": { |
# passport-firebase-jwt | ||
Based on [passport-jwt](https://github.com/mikenicholson/passport-jwt) | ||
A [Passport](http://passportjs.org/) strategy for authenticating with a Firebase Auth. | ||
This module lets you authenticate endpoints when using Firebase Auth. | ||
A [Passport](http://passportjs.org/) strategy to authenticate with Firebase Auth. | ||
This module lets you authenticate endpoints when using Firebase Auth in a Node.js application. | ||
## Install | ||
@@ -16,3 +17,25 @@ | ||
Strategy name is: `firebase-jwt`. | ||
#### index.ts | ||
Make sure firebase is initialized before starting NestJs | ||
```ts | ||
import { credential, initializeApp } from 'firebase-admin'; | ||
import * as express from 'express'; | ||
import * as serviceAccount from './serviceAccountKey.json'; | ||
const config = { | ||
apiKey: '***', | ||
authDomain: '***.firebaseapp.com', | ||
databaseURL: 'https://***.firebaseio.com', | ||
projectId: '***', | ||
storageBucket: '***.appspot.com', | ||
messagingSenderId: '***', | ||
credential: credential.cert(***) | ||
}; | ||
initializeApp(config); | ||
``` | ||
#### firebase-auth.strategy.ts | ||
```ts | ||
import { PassportStrategy } from '@nestjs/passport'; | ||
@@ -43,2 +66,22 @@ import { Injectable, UnauthorizedException } from '@nestjs/common'; | ||
#### auth.module.ts | ||
```ts | ||
import { Module } from '@nestjs/common'; | ||
import { PassportModule } from '@nestjs/passport'; | ||
import { FirebaseAuthStrategy } from './firebase-auth.strategy'; | ||
@Module({ | ||
imports: [ | ||
PassportModule.register({ defaultStrategy: 'firebase-jwt' }) | ||
], | ||
providers: [ | ||
FirebaseAuthStrategy | ||
], | ||
exports: [ | ||
PassportModule | ||
] | ||
}) | ||
export class AuthModule {} | ||
``` | ||
### Extracting the JWT from the request | ||
@@ -45,0 +88,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
22
466
109
0
25940
6