Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-firebase-authentication

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-firebase-authentication

Firebase Strategy

  • 0.0.0-beta.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

passport-firebase-auth

Firebase Strategy base on firebase authentication

You must call firebase.initializeApp before use this Strategy.

Install

$ npm install passport-firebase-auth

Usage

Create an Application

Before using passport-firebase-auth, you must register an application with Firebase. If you have not already done so, a new project can be created in the Firebase Developers Console.

Configure Strategy

The Firebase authentication strategy authenticates users using a Firebase Token.

You must call

 firebase.initializeApp({
     serviceAccount: "path/to/serviceAccountCredentials.json",
     databaseURL: "https://databaseName.firebaseio.com"
 });

 

before using this strategy.

var FirebaseStrategy = require('passport-firebase-auth').Strategy;

passport.use(new FirebaseStrategy({
    firebaseProjectId: "project-id",
    authorizationURL: 'https://account.example.net/auth',
    callbackURL: 'https://www.example.net/auth/firebase/callback'
  },
  function(accessToken, refreshToken, decodedToken, cb) {
    User.findOrCreate(..., function (err, user) {
      return cb(err, user);
    });
  }
));
Authenticate Requests

Use passport.authenticate(), specifying the 'firebaseauth' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/firebase',
  passport.authenticate('firebaseauth', { }));

app.get('/auth/firebase/callback', 
  passport.authenticate('firebaseauth', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Examples

License

The MIT License

Keywords

FAQs

Package last updated on 27 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc