Giter Site home page Giter Site logo

redis-gcra's People

Contributors

akremer avatar dependabot[bot] avatar eeerin avatar rjhilgefort avatar spacetc62 avatar vivedo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis-gcra's Issues

Wrong redis key expire time?

I had check the lua script and found some part unexpected:

// https://github.com/Losant/redis-gcra/blob/master/lib/gcra.lua#L51
redis.call("SET", rate_limit_key, new_tat, "EX", reset_in)

The expire time of the key will be set to reset_in in seconds(EX), but in the reset_in value is in milliseconds.
That means that in most cases, the key will not expire at all(because it requires so much time to expire and will be reset in a short time).
Although this does not influence the whole functionality of the gcra algorithm because it will take the bigger one between now and the value of the key:

// https://github.com/Losant/redis-gcra/blob/master/lib/gcra.lua#L19
tat = math.max(tat, now)

But I think it should be corrected in case of making confusion.

Incorrect retryIn?

I'm trying to set up a simple password rate limiter, and I want to allow 6 attempts per minute.

I set it up like this:

  const {limited, retryIn} = await limiter.limit({
    key: `signin/email/${email.trim().toLowerCase()}`,
    burst: 6,
    rate: 6,
    period: 60000,
    cost: 1
  });

When I do too many sign ins I eventually get a retryIn of 10, but then it gets down to below 5 and then the next request is allowed!

Is this an issue with the rate limiter allowing too many requests through, or an issue with the retryIn?

Or is it an issue in how I'm configuring this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.