Skip to content

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

Merged
repo-ranger[bot] merged 14 commits into
mainfrom
jsjoeio/fix-login-rate-limiter
Apr 19, 2021
Merged

repo-ranger[bot] merged 14 commits into
mainfrom
jsjoeio/fix-login-rate-limiter

Conversation

@jsjoeio

@jsjoeio jsjoeio commented Apr 15, 2021 •

Copy link
Copy Markdown
Contributor

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 the v3.9.4 milestone Apr 15, 2021
Comment thread test/config.ts
Comment thread test/config.ts Outdated
Comment thread test/e2e/login.test.ts
Comment thread test/e2e/login.test.ts Outdated
@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

@oxy oxy left a comment

Copy link
Copy Markdown

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.

Comment thread src/node/routes/login.ts
Comment thread src/node/routes/login.ts
Comment thread test/unit/routes/login.test.ts Outdated
@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 code-asher and oxy April 16, 2021 21:25
Comment thread src/node/routes/login.ts Outdated
Comment thread src/node/routes/login.ts Outdated
oxy
oxy previously requested changes Apr 19, 2021

@oxy oxy left a comment

Copy link
Copy Markdown

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!

Comment thread test/unit/routes/login.test.ts Outdated
jsjoeio added 10 commits April 19, 2021 10:40
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 code-asher and oxy April 19, 2021 18:22
Comment thread test/e2e/login.test.ts
@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.

@oxy oxy left a comment

Copy link
Copy Markdown

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

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