npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@virgilsecurity/passport-pythia

v1.0.0

Published

Passport strategy for authenticating with Virgil Pythia

Downloads

4

Readme

This README is for @virgilsecurity/passport-pythia v1.0.0. Check the v0.1.x branch for an old version.

@virgilsecurity/passport-pythia

npm Build Status GitHub license

Passport strategy for authenticating with the Virgil Pythia PRF service.

This module lets you authenticate using a username and password while protecting the passwords cryptographically using the Pythia PRF service. We'll refer to passwords protected with the Pythia PRF service as Breach-Proof Password.

By plugging into Passport, Breach-Proof Password support can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Pre-requisites

  • Create a free Virgil Security account.
  • Create a Breach-Proof Password Storage app in the Virgil Security Dashboard.
  • Create an API Key in the Virgil Security Dashboard.

Install

npm install @virgilsecurity/passport-pythia

This module depends on virgil-pythia module to be installed to be able to communicate with the Virgil Pythia PRF service and perform the cryptographic operations necessary to verify the passwords.

npm install virgil-pythia

You also need to install @virgilsecurity/pythia-crypto and virgil-crypto, unless plan to use custom crypto implementations.

npm install @virgilsecurity/pythia-crypto virgil-crypto

Usage

Configure strategy

The strategy requires two parameters. The first is an instance of Pythia class from the virgil-pythia module. The second is a getAuthenticationParams callback, which is responsible for retrieving the breach-proof password parameters of the user making the request. It accepts the request object and a callback to be called with an error as a first argument, if any, and the breach-proof password parameters as the second argument.

passport.use(new PythiaStrategy(
    virgilPythia,
    (request, cb) => {
        User.findOne({ username: request.body.username }, (err, user) => {
            if (err) return cb(err);
            if (!user) return cb(new Error('Invalid username'));
            cb(null, {
                user,
                password: request.body.password,
                salt: user.bppSalt,
                deblindedPassword: user.bppDeblindedPassword,
                version: user.bppVersion
            });
        });
    }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'pythia' strategy, to authenticate requests. For example, as route middleware in an Express application:

app.post(
  '/sign-in',
  passport.authenticate('pythia', {
    successRedirect: '/profile',
    failureRedirect: '/sign-in',
  }),
);

Examples

Developers using the Express web framework can refer to an example as a starting point for their own web applications.

Tests

To run this example on your computer, clone this repository and install dependencies.

git clone https://github.com/VirgilSecurity/virgil-passport-pythia.git
cd passport-pythia
npm install

Create a new file named .env with the contents of .env.example

cp .env.example .env

Open the .env file in a text editor and replace the values starting with [YOUR_VIRGIL_... with the corresponding values from your Virgil Dashboard.

Run the tests.

npm test

License

This library is released under the BSD 3-Clause License.