Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
passport-strategy
Advanced tools
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.
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
}
}
Implements a local authentication strategy using a username and password. It is more specific compared to passport-strategy, which is a generic interface for any type of authentication.
Implements an OAuth 2.0 authentication strategy, providing mechanisms to authenticate with third-party services. It contrasts with passport-strategy by focusing specifically on OAuth 2.0 protocol.
Provides strategies for authenticating with HTTP mechanisms such as Basic and Digest authentication. Unlike passport-strategy, which is a framework, passport-http offers concrete implementations for these HTTP authentication methods.
An abstract class implementing Passport's strategy API.
$ npm install passport-strategy
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.
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 autheticate()
, performing the necessary operations required by the
authentication scheme or protocol being implemented.
CustomStrategy.prototype.authenticate = function(req, options) {
// TODO: authenticate request
}
$ npm install
$ npm test
Copyright (c) 2011-2013 Jared Hanson <http://jaredhanson.net/>
FAQs
An abstract class implementing Passport's strategy API.
The npm package passport-strategy receives a total of 2,372,330 weekly downloads. As such, passport-strategy popularity was classified as popular.
We found that passport-strategy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.