GithubHelp home page GithubHelp logo

sacsand / express-firebase-auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leafycode/express-firebase-auth

0.0 1.0 0.0 52 KB

Firebase authentication middleware for Express.

License: MIT License

JavaScript 100.00%

express-firebase-auth's Introduction

Express Firebase Auth Middleware

npm version

Authenticate your endpoints with Firebase auth.

Features:

  • Authenticate the user using Firebase before running the function.
  • Ability to skip authentication on public API endpoints.

Installing / Getting started

yarn add express-firebase-auth

In your app:

// Get this credentials file from the Firebase console.
import serviceAccount from '../firebase-config.json';
// Import the package
import { createFirebaseAuth } from 'express-firebase-auth';

// Initialize the firebase auth
const firebaseAuth = createFirebaseAuth({
  serviceAccount,
  ignoredUrls: [
    '/ignore'
  ]
});
app.use(firebaseAuth);
Option Value
serviceAccount (Note1) Obtain this from firebase
firebase (Note1) An initialized firebase app. Refer Firebase setup
ignoredUrls (Optional) An array of URLs where you need to skip the authentication.
checkEmailVerified (Optional) (Default: false) If set to true, only users with a verified email will be allowed access.
checkEmailVerifiedIgnoredUrls (Optional) An array of URLs where you need to skip the email verified check.

Note1

You must provide either the serviceAccount credentials or an already initialized firebase app. If you are planning to use other services of Firebase in your app, you should initialize your own app. If you only want the authentication part, you can simply pass the serviceAccount credentials and express-firebase-auth will initialize the app for you. You cannot initialize two firebase apps.

This package adds the user object returned by firebase to res.locals.user. You can use that inside your functions.

Developing

Prerequisites

Setting up Dev

Clone the repo and run yarn install. Make sure you have an editor with an eslint plugin active. Never start working without eslint.

Versioning

We use SemVer for versioning. For the versions available, see the link to tags on this repository.

Style guide

Always follow the AirBnb Style Guide.

License

MIT licensed.

express-firebase-auth's People

Contributors

sashahilton00 avatar thpubs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.