Skip to content

Conversation

@SemVerTsar
Copy link
Contributor

Currently, refreshing a password reset request page (3 or more times) that does an OPTIONS to get fields, will block you from requesting the fields for a day.

We should only be rate limiting POST requests.

cc @meshy @ian-foote

@perry perry added the bug label Oct 17, 2014
@LilyFirefly
Copy link

This looks easy enough to do. We can check the request.method in the throttle's allow_request method. See the Custom Throttles example.

@mlen108
Copy link
Contributor

mlen108 commented Oct 27, 2014

x

@SemVerTsar SemVerTsar self-assigned this Oct 28, 2014
@SemVerTsar
Copy link
Contributor

@ian-foote or @meshy Please review.

Choose a reason for hiding this comment

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

Do you need to recreate the request each time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, as the request is being processed items are popped from the data structure. So the request cannot be reused.

Choose a reason for hiding this comment

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

Pity.

now only rate limits post

Choose a reason for hiding this comment

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

You could add a helper method to make this more DRY. Something like:

def check_post_rate_limit(self, view, data, expected_status):
    request = self.create_request('post', data=data, auth=False)
    response = view(request)
    self.assertEqual(response.status_code, expected_status)

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@SemVerTsar
Copy link
Contributor

@ian-foote Please take another look

@SemVerTsar
Copy link
Contributor

I moved it out with a look to adapting check_post_rate_limit() to work with different request types

@SemVerTsar
Copy link
Contributor

@meshy or @ian-foote could you take another look

Copy link
Contributor

Choose a reason for hiding this comment

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

Would assert_post_returns_status be more appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@SemVerTsar
Copy link
Contributor

Update

@meshy
Copy link
Contributor

meshy commented Oct 30, 2014

Happy if travis is

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling c418ca7 on options-rate-delimit into 54fb754 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling c418ca7 on options-rate-delimit into 54fb754 on master.

LilyFirefly pushed a commit that referenced this pull request Oct 30, 2014
OPTIONS requests shouldn't be rate limited
@LilyFirefly LilyFirefly merged commit e353acc into master Oct 30, 2014
@LilyFirefly LilyFirefly deleted the options-rate-delimit branch October 30, 2014 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants