Socket
Socket
Sign inDemoInstall

@dylan/csrf

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dylan/csrf

Middleware for Dylan which can generate csrf tokens and protect from csrf attacks.


Version published
Weekly downloads
47
increased by9.3%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

CSRF

Middleware for Dylan which can generate csrf tokens and protect from csrf attacks.

Install

npm install @dylan/csrf

Usage

const dylan = require('dylan');
const session = require('@dylan/session');
const csrf = require('@dylan/csrf');
const app = dylan();

app.use(session({
  cookie: 'foo',
  secret: 'boo'
}));

app.use(csrf());

app.get('/contact', (req, res) => {
  res.send(`
    <form method="post" action="/contact">
      <input type="hidden" name="csrf-token" value="${res.locals.csrfToken}">
      <input type="text" name="message" value="hello world">
      <button>Talk</button>
    </form>
  `);
});

app.post('/contact', (req, res) => {
  console.log(req.body.message); // hello world
  res.end('safely handled');
});

Keywords

FAQs

Last updated on 13 Oct 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc