New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-masquerade

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-masquerade

masquerade as other users

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

express-masquerade

NPM Version NPM Downloads Node.js Version Build Status Coverage Status Gittip

Masquerade as other users via x-masquerade-as header middleware. Plays well with passport.

Add it as middleware. The first parameter is a function that gets a user by id:

var express = require('express');
var masquerade = require('express-masquerade');

var app = express();

app.use(masquerade(function(id, next) {
  User.find(id).complete(next);
}));

This will set req.user to the user with an id of 2:

curl localhost:3000/profile --header "x-masquerade-as: 2"

Installation

$ npm install express-masquerade

Options

Pass options as the second parameter:

app.use(require('express-masquerade')(getUser, options));
header (string)

Use a different header than x-masquerade-as.

var options = {
  header: 'masquerading-as'
};
authorize (function)

Set a function to authorize whether or not the user has permission to masquerade. Should return true or false.

var options = {
  authorize: function(req) {
    return req.user.role === 'admin';
  }
};

MIT Licensed

Keywords

FAQs

Package last updated on 10 Sep 2014

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