WeDeploy Auth Middleware

raw JSON →
3.2.0 verified Sat May 09 auth: no javascript deprecated

Express middleware for authenticating requests using WeDeploy Auth service. Supports multiple authentication methods including Basic Auth, OAuth2 bearer tokens (header, query string, cookie). Version 3.2.0 is the latest stable release. Integrates with WeDeploy platform for federated identity providers. Requires Node.js >= 7.6.0. Note: WeDeploy service is deprecated; use only for legacy systems.

error TypeError: wedeployMiddleware.auth is not a function
cause Using ES module import syntax with CommonJS package.
fix
Use require() instead of import.
error Cannot find module 'wedeploy-middleware'
cause Package not installed or missing from node_modules.
fix
Run: npm install wedeploy-middleware
deprecated WeDeploy service is deprecated. This middleware will not work with new projects.
fix Migrate to a different authentication middleware like passport.js.
gotcha Auth middleware does not run on unmatched routes; must be applied per route or globally.
fix Use app.use(middleware) to apply globally.
gotcha The option 'unauthorizedOnly' may prevent access to routes intended for unauthenticated users.
fix Set 'unauthorizedOnly' only on routes where no user should be logged in.
npm install wedeploy-middleware
yarn add wedeploy-middleware
pnpm add wedeploy-middleware

Sets up Express app with WeDeploy auth middleware, protecting a private route.

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

const app = express();
const authUrl = process.env.AUTH_URL ?? 'auth.project.wedeploy.io';

app.use(wedeployMiddleware.auth({ url: authUrl }));

app.get('/private', (req, res) => {
  res.json({ user: res.locals.auth.currentUser });
});

app.listen(3000);