Socket
Socket
Sign inDemoInstall

onedionys-csrf-protection-middleware

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

onedionys-csrf-protection-middleware

One Dionys (CSRF Protection Middleware) - Middleware to protect applications from CSRF (Cross-Site Request Forgery) attacks by adding tokens to HTTP requests.


Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to One Dionys - CSRF Protection Middleware! 👋

Middleware to protect applications from CSRF (Cross-Site Request Forgery) attacks by adding tokens to HTTP requests. 💖

💾 Requirements

  • Web Browser - Can be used as an emulator to build applications. Example [Chrome, Firefox, Safari & Opera].
  • Internet - Because many use CDN and to make it easier to find solutions to all problems.

🎯 How To Use

Example Syntax
const express = require('express');
const session = require('express-session');
const csrfMiddleware = require('./src/csrfMiddleware');

const app = express();

// Setup session middleware
app.use(session({
    secret: 'your_secret_key',
    resave: false,
    saveUninitialized: true
}));

// Use CSRF protection middleware
app.use(csrfMiddleware);

// Your other middleware and routes

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});
Explanation
  • This middleware generates a CSRF token and stores it in the user's session. It adds this token to requests as a hidden field in forms or as a custom HTTP header. When the user submits a form or makes a request, the server verifies that the CSRF token matches the one stored in the session, protecting against CSRF attacks.
Return Value
  • The middleware returns a function that acts as middleware in Express.js applications. This function adds CSRF protection to routes by generating and storing CSRF tokens in user sessions.

📆 Release Date

  • v1.0.0 : 17 March 2024
  • v1.0.1 : 18 March 2024
  • v5.0.0 : 31 March 2024

🧑 Author

  • Facebook : Oned Ionys
  • Instagram : @onedionys
  • Twitter : @onedionys
  • LinkedIn : @onedionys

📝 License

  • Copyright © 2024 One Dionys
  • One Dionys - CSRF Protection Middleware is an open source project licensed under the MIT license

☕️ Suppport & Donation

Love One Dionys - CSRF Protection Middleware? Support this project by donating or sharing with others in need.

Made with ❤️ One Dionys

Keywords

FAQs

Package last updated on 31 Mar 2024

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