New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wedeploy-middleware

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wedeploy-middleware

WeDeploy middleware for Node.js

latest
Source
npmnpm
Version
3.2.0
Version published
Maintainers
3
Created
Source

wedeploy-middleware

Build Status npm version

Auth

Node.js middleware to help users to authenticate using passwords, popular federated identity providers like Google, Facebook, GitHub, and more using WeDeploy™ Auth.

How it works - For every request intercepted by the auth middleware a token or credential may be extracted in the following order:

SourceKey
Basic Authenticationcurl -u "username:password" "https://api.wedeploy.io/"
OAuth2 Token (header)curl -H "Authorization: Bearer TOKEN" "https://api.wedeploy.io/"
OAuth2 Token (query string)curl "https://api.wedeploy.io/?access_token=TOKEN"
OAuth2 Token (cookie)curl -H "Cookie:access_token=TOKEN" "https://api.wedeploy.io/"

Installation

$ npm install wedeploy-middleware

API

var express = require('express');
var wedeployMiddleware = require('wedeploy-middleware');

var app = express();
app.use(wedeployMiddleware.auth({url: 'auth.project.wedeploy.io'}));

wedeployMiddleware.auth(options)

  • options.url authorization service url passed to WeDeploy.auth(url).
  • options.redirect optional url to redirect on authentication failure, e.g. /login.
  • options.scopes optional authorization scopes.
  • options.scopesOr optional boolean, if true, users need only one passed in scope to be authorized
  • options.authorizationError optional authorization error response body, e.g. {status: 401, message: 'Unauthorized'}.
  • options.unauthorizedOnly optional check ensuring that there's no logged user for the current route, e.g. true.

Examples

Basic usage

var express = require('express');
var wedeployMiddleware = require('wedeploy-middleware');

var app = express();
app.use(wedeployMiddleware.auth({url: 'auth.project.wedeploy.io'}));

app.get('/private', function(req, res) {
  // User that has been signed in
  console.log('User: ', res.locals.auth.currentUser);
});

app.listen(8080);

Authenticating with scopes

var express = require('express');
var wedeployMiddleware = require('wedeploy-middleware');

var app = express();

var authMiddleware = wedeployMiddleware.auth({
  url: 'auth.project.wedeploy.io',
  scopes: ['superuser', 'manager']
});

app.get('/admin', authMiddleware, function(req, res) {
  // User that has been signed in
  console.log('User: ', res.locals.auth.currentUser);
});

app.listen(8080);
// curl http://localhost:8080/private -H 'Authorization: Bearer token' -v
// curl http://localhost:8080/private -H 'Authorization: Basic dXNlcjpwYXNz' -v

MIT Licensed

Keywords

auth

FAQs

Package last updated on 29 Jan 2019

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