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

@akoenig/sso

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@akoenig/sso

Opinionated wrapper around Passport.js. It supports logins via Facebook and local users.

  • 1.2.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

@akoenig/sso

Opinionated wrapper around Passport.js. It supports logins via Facebook and local users.

Installation

npm install --save @akoenig/sso

Usage

Facebook

The following describes the configuration for performing a Facebook SSO

const app = express();

const restricted = sso(app, {
    facebook: {
        clientID: "<the-facebook-app-client-id>",
        clientSecret: "<the-facebook-app-client-secret>",
        callbackURL: "http://localhost:8080/auth/facebook/callback",
        successRedirect: "/",
        failureRedirect: "/login",
        authenticated: async (profile) => {
            // Insert or Update in database
        }
    }
});

This results in a new handler which can be accessed via GET /auth/facebook. The user gets redirected to Facebook and has to perform the authentication process there. Afterwards the user will be send back to callbackUrl by Facebook.

Local

The following describes the configuration for performing a local SSO (own users in a database):

const restricted = sso(app, {
    local: {
        verify: (username, password, callback) => {
            const user = YOUR_DATABASE.findUserByUsername(username);

            if (!user || user.password !== password) {
                return callback(null, false);
            }

            callback(null, user);
        },
        successRedirect: "/",
        failureRedirect: "/login",
    },
});

This registers the following route handler: POST /auth/local. You can perform a request against that route with the help of a form:

<form action="/auth/local" method="post">
    <input type="text" name="username">
    <input type="password" name="password">

    <input type="submit" value="Login">
</form>

Each time the user submits that form, the provided verify function gets executed. You have to verify the user within that function by gathering the user from your database. The parameters username and password are filled with the values from the form.

FAQs

Package last updated on 23 Jun 2017

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