Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-drupal7-session-middleware

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-drupal7-session-middleware

Express middleware to retrieve a user session from a drupal 7 cookie

  • 1.2.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Express middleware to retrieve a user session from a drupal 7 cookie

Express middleware for Drupal 7 authentication

CircleCI Greenkeeper badge

Install

npm i express-drupal7-session-middleware

You need to use knex query builder to use this package.

npm i cookie-parser knex

See knex documentation on how to create a new instance.

Usage

In your server definition


  const { drupalExpressMiddleware } = require('express-drupal7-session-middleware');

  app.httpServer = http.createServer(app);
  // ...
  app.use(cookieParser());
  app.use(drupalExpressMiddleware('local.my-website.com', knex));

then in your routes

  const { drupalUserAccess, drupalCSRFToken } = require('express-drupal7-session-middleware');

  const myRoute = async (req, res) => {
    const access = await drupalUserAccess(knex, 'access api myRoute', req.userId);
    if (!access) {
      return res.status(403).send();
    }

    // Bonus if you need it
    console.log(req.cookieSessionText);
    // -- and --
    const drupalHashSalt = 'fwf3qfwgrbq34h34qeg134g3434g5340f-0f';
    const csrfToken = await drupalCSRFToken(knex, req.sessionId, drupalHashSalt, 'services'));
    res.json({ csrfToken });
  }

FAQs

Package last updated on 29 Dec 2022

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