Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: session uid ratelimit #136

Merged
merged 6 commits into from
May 8, 2019
Merged

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
Member

@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
Member

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
Member

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
Member

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
Member

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 AmbireTech: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