Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
ralphi
Advanced tools
Readme
Ralphi
is a simple rate limiting server intended to prevent bruteforce attacks on logins and other sensitive assets. it is very loosely base on limitd but it is much more simple.
Main difference to limitd
-
take
or reset
a recordRalphi currently has 4 independent npm modules to it
$ npm install -s ralphi
$ npm install -s ralphi-client
# if you wish to use it with hapi install the hapi plugin
$ npm install -s hapi-ralphi
$ npx ralphi login,5,10m
The above command will start Ralphi
with a single login
bucket that allows for 5 request every 10 minutes
For more information see the Config section or run ralphi --help
const plugin = require('hapi-ralphi');
const client = new require('ralphi-client')();
const server = new require('hapi').Server();
async function init () {
await server.register({plugin, options: {client}});
server.route({
method: 'POST',
path: '/login',
config: {
plugins: {
ralphi: {
bucket: 'login'
}
}
},
handler () {
return 'Success';
}
});
}
init();
login
root will be rate limited according to the bucket settings, and rate limiting headers will be sent with the response.
For more information see hapi-ralphi
const express = require('express');
const app = express();
const RateLimit = require('express-ralphi');
const client = new require('ralphi-client')();
app.use('/login', RateLimit({bucket: 'login', client}));
app.get('/login', (rec, res) => res.send('Success'));
login
root will be rate limited according to the bucket settings, and rate limiting headers will be sent with the response.
For more information see express-ralphi
const client = new require('ralphi-client')();
async function handler (req, res) { //in your handler code
const limit = await client.take('login', req.ip);
if (limit.conformant) {
//allow access
return `Request was done. You have ${limit.remaining} more requests until ${new Date(limit.ttl * 1000)}`;
} else {
//reject access
throw new Error(`You have made too many requests. You can send ${limit.size} requests after ${new Date(limit.ttl * 1000)}`);
}
}
For more information see ralphi-client
You can use the following command line flags to configure Ralphi -
Other than settings the flags Ralphi requires you to define buckets to be used for rate limiting -
$ ralphi login,10,30m token,2,1h
Using the above command Ralphi will start with two buckets defined
bucket name must be alphanumeric and ttl value can have a unit prefix (ms,s,m,h) or it will default to seconds
Config need to be in a json format.
{
"host": "localhost",
"port": 8910,
"cleanInterval": 1800,
"buckets": {
"login": {
"size": 10,
"ttl": "30m"
}
},
}
FAQs
Rate limit and bruteforce prevention api server
The npm package ralphi receives a total of 20 weekly downloads. As such, ralphi popularity was classified as not popular.
We found that ralphi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.