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

api-security-gateway

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-security-gateway

A security gateway for APIs with rate limiting, IP whitelisting, and injection prevention.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by37.5%
Maintainers
0
Weekly downloads
 
Created
Source

api-security-gateway

API Security Gateway

A security gateway for APIs with features such as rate limiting, IP whitelisting, and injection prevention. This library helps you secure your APIs by controlling access and preventing common attack vectors.

Features

  • Rate Limiting: Control the number of requests a user can make within a specified timeframe.
  • IP Whitelisting/Blacklisting: Allow or deny requests based on IP addresses.
  • Injection Prevention: Sanitize inputs to prevent SQL injection, XSS, and other injection attacks.

Installation

You can install the library using npm:

npm install api-security-gateway


A security gateway for APIs with features such as rate limiting, IP whitelisting, and injection prevention. This library helps you secure your APIs by controlling access and preventing common attack vectors.

## Features

- **Rate Limiting**: Control the number of requests a user can make within a specified timeframe.
- **IP Whitelisting/Blacklisting**: Allow or deny requests based on IP addresses.
- **Injection Prevention**: Sanitize inputs to prevent SQL injection, XSS, and other injection attacks.

## Installation

```bash
git clone https://github.com/yourusername/api-security-gateway.git
cd api-security-gateway
npm install

Using with Express

Here's an example of how to use the api-security-gateway library in an Express application:

const express = require("express");
const apiSecurityGateway = require("api-security-gateway");

const app = express();
app.use(express.json());

const securityOptions = {
  rateLimit: {
    maxRequests: 100,
    windowMs: 15 * 60 * 1000, // 15 minutes
  },
  ipFilter: {
    whitelist: ["127.0.0.1"],
    blacklist: ["192.168.1.1"],
  },
};

const securityGateway = apiSecurityGateway(securityOptions);

app.use((req, res, next) => {
  const requestInfo = {
    ip: req.ip,
    body: req.body,
    query: req.query,
    params: req.params,
  };

  const result = securityGateway(requestInfo);
  if (result.status === 200) {
    next();
  } else {
    res.status(result.status).json({ message: result.message });
  }
});

app.get("/secure-endpoint", (req, res) => {
  res.send("This is a secure endpoint");
});

app.listen(3000, () => {
  console.log("Server running on port 3000");
});

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 09 Jul 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