1.3.4 • Published 6 years ago

express-firebase-auth v1.3.4

Weekly downloads
30
License
MIT
Repository
github
Last release
6 years ago

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);
OptionValue
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.

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

1.0.0-alpha2

7 years ago

1.0.0-alpha1

7 years ago