Skip to content

Comments

add: session uid ratelimit#136

Merged
Ivshti merged 6 commits intoadexAI:masterfrom
samparsky:rate-limit-uid
May 8, 2019
Merged

add: session uid ratelimit#136
Ivshti merged 6 commits intoadexAI:masterfrom
samparsky:rate-limit-uid

Conversation

@samparsky
Copy link
Contributor

fixes #132

@samparsky samparsky force-pushed the rate-limit-uid branch 4 times, most recently from 311db44 to a5fc577 Compare April 29, 2019 17:29
Copy link
Contributor

@Ivshti Ivshti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've done a very good job on this, but I have a few remarks

I'm also wondering if we should match multiple rules or not

if we do, we should .map on rules and each one should return an async function (therefore a promise) and we should then await Promise.all ; basically do the rule checking in parallel

@@ -19,7 +20,10 @@ function getMongo() {
}

function getRedis() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice touch

: [
{ uids: [channel.creator] },
{ uids: null, rateLimit: cfg.IP_RATE_LIMIT },
{ uids: null, rateLimit: cfg.SID_RATE_LIMIT }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be default

test/index.js Outdated
const events = genEvents(2, 'working')
const allowOnlyOneEvent = await checkAccess(channel, {}, events)
t.equal(allowOnlyOneEvent.success, false, 'should not process request')
t.equal(allowOnlyOneEvent.statusCode, 429, 'shoudl ahbe err')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the typos please

test/index.js Outdated

// redis connection preventing test from closing
// hence the quit
tape.onFinish(() => db.getRedis().quit())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a separate test file, since it's more similar to an integration test then a unit test because it requires redis and is not a pure function

@Ivshti Ivshti merged commit 0e5f95e into adexAI:master May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sentry: rateLimit type "uid"

2 participants