Top Free Javascript User Authentication Libraries

by admin Date: 27-02-2019 javascript authentication libraries

We are keen on security: authentication is an important issue when creating a dynamic web application

Authentication is for identifying users and provide different access rights and content depending on their id. Since new tutorials appear on the web and more people try to understand the cost-benefit equation for implementing their own solution vs. using a library or service, we have gathered a brief review of what's out there.

Let's see.

1. Passport JS

.Passport is Express-compatible authentication middleware for Node.js.

Passport's sole purpose is to authenticate requests, which it does through an extensible set of plugins known as strategies. Passport does not mount routes or assume any particular database schema, which maximizes flexibility and allows application-level decisions to be made by the developer. The API is simple: you provide Passport a request to authenticate, and Passport provides hooks for controlling what occurs when authentication succeeds or fails.

Passport is not just a 15k star user-auth library, it is probably the most common way to use an external library for user authentication by JS developers. Basically, this library offers Node.js relatively flexible and modular middleware that can be integrated into any web application based on Express.

2. Permit

Before Permit, the only real choice for authentication libraries in Node.js was Passport.js. But it has a bunch of issues that complicate your codebase. Permit makes it easy to add an authentication layer to any Node.js API. It can be used with any of the popular server frameworks (eg. Express, Koa, Hapi, Fastify) and it can be used for any type of API (eg. REST, GraphQL, etc.) due to its simple, unopinionated design.


Permit lets you authenticate via the two schemes most APIs need: a single secret bearer token, or a set of username and password credentials. For example, here's how to authenticate a bearer token:


import { Bearer } from 'permit'

// A permit that checks for HTTP Bearer Auth, falling back to a query string.
const permit = new Bearer({
  query: 'access_token',

async function handler({ req, res }) {
  // Try to find the bearer token in the request.
  const token = permit.check(req)

  // No token, that means they didn't pass credentials!
  if (!token) {
    throw new Error(`Authentication required!`)

  // Authenticate the token however you'd like...
  const user = await db.users.findByToken(token)

  // No user, that means their credentials were invalid!
  if (!user) {
    throw new Error(`Authentication invalid!`)

  // They were authenticated, so continue with your business logic...

Since Permit isn't tightly coupled to a framework or data model, it gives you complete control over how you write your authentication logic—the exact same way you'd write any other request handler.

Differences between Permit and Passport:

  • Passport is not focused on authenticating APIs. Passport is focused on authenticating web apps with services like Facebook, Twitter and GitHub. APIs don't need that, so all the extra bloat means lots of complexity for no gain.

  • Passport is tightly-coupled to Express. If you use Koa, Hapi, Fastify, or some other framework you have to go to great lengths to get it to play nicely.

  • Other middleware are tightly-coupled to it. Passport stores state on the req object, so all your other middleware become tightly coupled to its implementation, making your codebase brittle.

  • It results in lots of hard to debug indirection. Because of Passport's black-box architecture, whenever you need to debug an issue it's causing you have to trace its logic across many layers of indirection and many repositories.

  • It's not very actively maintained. Passport's focus on OAuth providers means that it takes on a huge amount of scope, across a lot of repositories, many of which are not actively maintained anymore.

3. Grant

A relatively new and promising library with more than 180 supported providers and a live playground for Express, Koa and Hapi with OAuth Middleware. If you want to use it with your own private OAuth provider, you can specify the required key. Although this library already has traction (+ 1 K stars), it has relatively few resources, so try carefully.

4. Feathers

Feathers is an open source web framework for NodeJS that allows you to control your data through RESTful resources, sockets and flexible plug-ins in real time. Feathers also offers authentication and authentication management modules that allow you to add verification, forgotten reset of passwords and other features to authenticate local feathers.

The general idea is to combine multiple methods of authentication in a flexible infrastructure under one roof.

5. Firebase Authentication (for small apps)

Firebase authentication is required to provide your users with read / write privileges via security rules. We have not yet covered security rules, but we only know that security rules depend on the authentication status of a user.

Firebase ships Google, Facebook, Twitter and GitHub with its own email / password auth and OAuth2 integrations. You can also integrate your own authors with Firebase Authentication to provide users with access to data without forcing them to create an account outside your existing systems.

Firebase Auth includes a user management system. You can save some basic data against your Firebase Auth users, and you offer multiple login methods -- email/password, Google, Facebook…-- and link your users’ accounts into single Firebase Auth user accounts. Auth also provides for integrations into your pre-existing auth system so that your app can take advantage of Firebase’s security rules.

Firebase may not be the long - term solution for managing user auth on your scaling platform (or is it?). But it's a very useful way to get your applications deployed with Firebase done, quickly and easily.



Business vector created by -

by admin Date: 27-02-2019 javascript authentication libraries hits : 3338  

Related Posts