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

fi-security

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fi-security

Security component for Node.js Express applications

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

Fi Security

Application security module for Node.js Express applications.

Installing

npm install --save fi-security

Usage

Initialization

You must call it with your Express' application instance, to attach the routes, and a configuration object. It's important to initialize the Express' session before you configure Fi Security:

var session = require('express-session');
var security = require('fi-security');
var express = require('express');

var app = express();

app.use(session());

security(app, config);

/* And now your routes... */
app.get('/', (req, res, next) => {
  //...
});

Configuration

The configuration Object must be pretty much like a Fi Aegis configuration Object, since this module is based on it.

  • debug: This option can be a Function to log with or a Boolean. If true it'll use console.log.
  • csrf: Same as Fi Aegis with the addition of the exclude property:
    • exclude: An array of routes with their method(s) and path(s) to be excluded from CSRF checks:
      • method: A single POST, PUT or DELETE method or an array of them. Empty means ALL.
      • path: A valid Express route path.
  • csp: Same as Fi Aegis.
  • xframe: Same as Fi Aegis.
  • hsts: Same as Fi Aegis.
  • nosniff: Same as Fi Aegis.
  • xssProtection: Same as Fi Aegis.
  • p3p: Same as Fi Aegis.
Example configuration
{
  debug: true,

  p3p: 'ABCDEF',

  csrf: {
    exclude: [{
      method: 'POST',
      path: '/no-csrf'
    }, {
      path: '/api/external'
    }]
  },

  xframe: 'DENY',

  xssProtection: {
    enabled: true
  },

  csp: {
    reportUri: 'https://example.com',
    policy: {
      'default-src': "'self'"
    }
  },

  hsts: {
    includeSubDomains: true,
    maxAge: 31536000
  },

  nosniff: true
}

Using with AngularJS

Just add this to your Fi Security configuration:

//...

csrf: {
  angular: true
  //...
}

//...

See this for more information regarding AngularJS' XSRF approach.

Keywords

FAQs

Package last updated on 31 Dec 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

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