Socket
Socket
Sign inDemoInstall

passport-strategy

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    passport-strategy

An abstract class implementing Passport's strategy API.


Version published
Weekly downloads
2.3M
increased by0.63%
Maintainers
1
Install size
5.78 kB
Created
Weekly downloads
 

Package description

What is passport-strategy?

The passport-strategy package provides an interface for implementing authentication strategies in Node.js applications using the Passport authentication middleware. It is designed to be subclassed by specific strategy implementations, which define how authentication is performed.

What are passport-strategy's main functionalities?

Strategy Interface Creation

This code demonstrates how to create a custom authentication strategy by extending the base Strategy class provided by passport-strategy. Developers can implement their own authenticate method to define the authentication process.

const passport = require('passport-strategy');

class CustomStrategy extends passport.Strategy {
  constructor(verify) {
    super();
    this.name = 'custom';
    this._verify = verify;
  }

  authenticate(req, options) {
    // Custom authentication logic here
  }
}

Other packages similar to passport-strategy

Readme

Source

passport-strategy

Build Coverage Dependencies

An abstract class implementing Passport's strategy API.

Install

$ npm install passport-strategy

Usage

This module exports an abstract Strategy class that is intended to be subclassed when implementing concrete authentication strategies. Once implemented, such strategies can be used by applications that utilize Passport middleware for authentication.

Subclass Strategy

Create a new CustomStrategy constructor which inherits from Strategy:

var util = require('util')
  , Strategy = require('passport-strategy');

function CustomStrategy(...) {
  Strategy.call(this);
}

util.inherits(CustomStrategy, Strategy);
Implement Authentication

Implement autheticate(), performing the necessary operations required by the authentication scheme or protocol being implemented.

CustomStrategy.prototype.authenticate = function(req, options) {
  // TODO: authenticate request
}

Tests

$ npm install
$ npm test

Credits

License

The MIT License

Copyright (c) 2011-2013 Jared Hanson <http://jaredhanson.net/>

Keywords

FAQs

Last updated on 01 Aug 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc