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

fix(login): rate limiter shouldn't count successful logins #3141

Merged
merged 14 commits into from Apr 19, 2021

Conversation

jsjoeio
Copy link
Contributor

@jsjoeio jsjoeio commented Apr 15, 2021

This PR fixes the login rate limiter to not count successful logins. This is important because it was causing issues with the e2e tests hitting the rate limit even though the logins were successful.

Changes

  • adds unit test for RateLimiter
  • moves loginPage.test.ts into login.test.ts
  • adds e2e tests for missing password, wrong password (and rate limiter)
  • adds new method to RateLimiter.canTry() to check remaining tokens

Fixes #2647

@jsjoeio jsjoeio self-assigned this Apr 15, 2021
@jsjoeio jsjoeio changed the title jsjoeio/fix-login-rate-limiter fix(login): rate limiter shouldn't count successful logins Apr 15, 2021
@jsjoeio jsjoeio added this to 🚧 In progress in Improve Testing via automation Apr 15, 2021
@jsjoeio jsjoeio added this to the v3.9.4 milestone Apr 15, 2021
test/config.ts Show resolved Hide resolved
test/config.ts Outdated Show resolved Hide resolved
test/e2e/login.test.ts Show resolved Hide resolved
test/e2e/login.test.ts Outdated Show resolved Hide resolved
@jsjoeio jsjoeio marked this pull request as ready for review April 15, 2021 23:52
@jsjoeio jsjoeio requested a review from a team as a code owner April 15, 2021 23:52
Copy link

@oxy oxy left a comment

Choose a reason for hiding this comment

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

Ratelimiter needs adjustment - see individual review comments.

src/node/routes/login.ts Outdated Show resolved Hide resolved
src/node/routes/login.ts Show resolved Hide resolved
test/unit/routes/login.test.ts Outdated Show resolved Hide resolved
@jsjoeio jsjoeio force-pushed the jsjoeio/fix-login-rate-limiter branch from 0d5f223 to fc85bf1 Compare April 16, 2021 21:25
@jsjoeio jsjoeio requested review from oxy and code-asher April 16, 2021 21:25
src/node/routes/login.ts Outdated Show resolved Hide resolved
src/node/routes/login.ts Outdated Show resolved Hide resolved
oxy
oxy previously requested changes Apr 19, 2021
Copy link

@oxy oxy left a comment

Choose a reason for hiding this comment

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

Just a few nits; looking in good shape otherwise!

test/unit/routes/login.test.ts Outdated Show resolved Hide resolved
Before, we weren't checking if a login was successful before counting it
against the rate limiter.

With this change, we only count unsuccessful logins against the rate limiter.

We did this because this was a bug but also because it caused problems with our
e2e tests hitting the rate limit.
This changes adds a new method called `.canTry` to the rate limiter to check if
there are tokens remaining in the bucket.

It also adds suggestions from @oxy to make sure the user can brute force past
the rate limiter.
@jsjoeio jsjoeio force-pushed the jsjoeio/fix-login-rate-limiter branch from fc85bf1 to 7928dc2 Compare April 19, 2021 17:41
@jsjoeio jsjoeio requested review from oxy and code-asher April 19, 2021 18:22
test/e2e/login.test.ts Show resolved Hide resolved
@jsjoeio jsjoeio force-pushed the jsjoeio/fix-login-rate-limiter branch from d23c37c to f80d5c3 Compare April 19, 2021 20:14
@jsjoeio jsjoeio dismissed oxy’s stale review April 19, 2021 20:14

I've made the requested changed and Asher has approved.

@jsjoeio jsjoeio added the merge when passing Merge the PR automatically once all status checks have passed label Apr 19, 2021
Copy link

@oxy oxy left a comment

Choose a reason for hiding this comment

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

All looks good!

@repo-ranger repo-ranger bot merged commit 6d65680 into main Apr 19, 2021
Improve Testing automation moved this from 🚧 In progress to ✅ Done Apr 19, 2021
@repo-ranger repo-ranger bot deleted the jsjoeio/fix-login-rate-limiter branch April 19, 2021 20:29
@jsjoeio jsjoeio added the testing Anything related to testing label May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when passing Merge the PR automatically once all status checks have passed testing Anything related to testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login rate limiter should not count against successful logins
4 participants