Skip to content

Conversation

@damienfa
Copy link
Contributor

@damienfa damienfa commented Jan 21, 2021

Q A
Branch 5.2
Bug fix no
New feature yes
Deprecations no
License MIT
Doc PR ⚠️ no doc

The only way to customize the default rate-limiter's options of the login_throttling (means fixed_window / 1 minute / 5 tokens) are through a custom limiter, which implies to declare a rate-limiter factory in the "framework.rate_limiter", a service which use this factory etc. It's really heavy just for changing an interval (moreover, 1 minute can be discutable).

In this PullRequest, I just propose to allow an interval option.

Example :

security:
  firewalls:
    main:
       login_throttling:
           max_attempts: 5
           interval: '15 minutes'

⚠️ At the time of writing, there is no Symfony documentation about the Login Throttling feature (only a blog post). Is there a reason to that ? Or may I propose something ?

…in_throttling"

The only way to customize the default rate-limiter's options of the login_throttling (means fixed_window / 1 minute / 5 tokens) are through a custom limiter, which implies to declare a rate-limiter factory in the "framework.rate_limiter", a service which use this factory etc. It's really heavy just for changing an interval (moreover, 1 minute can be discutable).
 
In this PullRequest, I just propose to allow an `interval` option. 

Example : 
```
security:
  firewalls:
    main:
       login_throttling:
           max_attempts: 5
           interval: '15 minutes'
```
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@wouterj
Copy link
Member

wouterj commented Jan 21, 2021

Hi @damienfa! Thanks for your time creating this PR. I think such an option makes lots of sense!

Are you willing to add a test for this new feature? (I can help if you are unsure how to do this) Also note the failing CS check in "fabbot.io" is related to this PR (there seems to be a trailing whitespace). At last, can you please add a small note to src/Symfony/SecurityBundle/CHANGELOG.md to say you introduce this new option?

At the time of writing, there is no Symfony documentation about the Login Throttling feature (only a blog post). Is there a reason to that ? Or may I propose something ?

Lacking time was the main factor (and we have to be careful to mention it only works when using experimental authenticators). I'm happy to review if you propose some docs for this feature.

@carsonbot carsonbot changed the title Add an easy way to customize "interval" in the default security.login_throttling [RateLimiter][Security] Add an easy way to customize "interval" in the default security.login_throttling Jan 21, 2021
@damienfa
Copy link
Contributor Author

damienfa commented Jan 22, 2021 via email

@wouterj
Copy link
Member

wouterj commented Jan 22, 2021

@nicolas-grekas nicolas-grekas added this to the 5.x milestone Jan 23, 2021
@damienfa
Copy link
Contributor Author

damienfa commented Feb 6, 2021

Hello @wouterj , as discussed I've added some functional test (improving the existing one here with an interval and two more login attempts). Also, I've fixed the fabbot.io check (it was due to a trailing space).

However, the Integration test (7.4) is now failing, and I don't understand which relation it has with my commit 🤷🏻‍♂️ Any help ?

@wouterj
Copy link
Member

wouterj commented Feb 6, 2021

No worries! The failures also occur in the 5.x branch: https://github.com/symfony/symfony/runs/1840808458 So they are certainly not your fault :)

I'll checkout this PR somewhere the coming days. Thanks for your update!

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

2 minor comments, looks good otherwise!

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you for this PR. This is great!

Could you fix the minor things so this can be merged in 5.3?

damienfa and others added 6 commits February 24, 2021 21:47
…n provided (Pierrick VIGNAND)

This PR was merged into the 4.4 branch.

Discussion
----------

MockResponse total_time should not be simulated when provided

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

When you provide a `total_time` to a MockResponse, it is overriden. It should be simulated only when it is not provided I guess.
Ex: `new MockResponse('{"foo":"bar"}', ['total_time' => 0.4])`

Commits
-------

8dada95 fix: MockResponse total_time should not be simulated when provided
…f is missing (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

improve exception message if symfony/security-csrf is missing

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix symfony#37452
| License       | MIT
| Doc PR        |

Commits
-------

1a26ed4 improve exception message if symfony/security-csrf is missing
@damienfa damienfa requested review from xabbuh and yceruto as code owners March 1, 2021 22:50
damienfa and others added 16 commits March 1, 2021 23:53
…in_throttling"

The only way to customize the default rate-limiter's options of the login_throttling (means fixed_window / 1 minute / 5 tokens) are through a custom limiter, which implies to declare a rate-limiter factory in the "framework.rate_limiter", a service which use this factory etc. It's really heavy just for changing an interval (moreover, 1 minute can be discutable).
 
In this PullRequest, I just propose to allow an `interval` option. 

Example : 
```
security:
  firewalls:
    main:
       login_throttling:
           max_attempts: 5
           interval: '15 minutes'
```
…in_throttling"

The only way to customize the default rate-limiter's options of the login_throttling (means fixed_window / 1 minute / 5 tokens) are through a custom limiter, which implies to declare a rate-limiter factory in the "framework.rate_limiter", a service which use this factory etc. It's really heavy just for changing an interval (moreover, 1 minute can be discutable).
 
In this PullRequest, I just propose to allow an `interval` option. 

Example : 
```
security:
  firewalls:
    main:
       login_throttling:
           max_attempts: 5
           interval: '15 minutes'
```
@damienfa damienfa changed the title [RateLimiter][Security] Add an easy way to customize "interval" in the default security.login_throttling [RateLimiter][Security] (obsolete ) Add an easy way to customize "interval" in the default security.login_throttling Mar 1, 2021
@damienfa damienfa changed the title [RateLimiter][Security] (obsolete ) Add an easy way to customize "interval" in the default security.login_throttling [RateLimiter][Security] (obsolete) Add an easy way to customize "interval" in the default security.login_throttling Mar 1, 2021
@damienfa
Copy link
Contributor Author

damienfa commented Mar 1, 2021

Sorry, I have to close this merge request. Following this comment I needed to rebase on branch 5.x.
Unfortunately, the "rebase" goes a way I've never experienced (it runs in a loop of conflicts and useless merge).
To do this, I simply created a new PR (see here) from this one. It's more readable, clearer.

@damienfa damienfa closed this Mar 1, 2021
fabpot added a commit that referenced this pull request Mar 2, 2021
…al` (in `security.firewalls`) option to change the default throttling interval. (damienfa, wouterj)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[RateLimiter][Security] Add a `login_throttling.interval` (in `security.firewalls`) option to change the default throttling interval.

| Q             | A
| ------------- | ---
| Branch       | 5.x
| Bug fix      |  no
| New feature  | yes
| Deprecations | no
| License       | MIT
| Doc PR        | ⚠️  no doc

The only way to customize the default rate-limiter's options of the login_throttling (means fixed_window / 1 minute / 5 tokens) are through a custom limiter, which implies to declare a rate-limiter factory in the "framework.rate_limiter", a service which use this factory etc. It's really heavy just for changing an interval (moreover, 1 minute can be discutable).

In this PullRequest, I just propose to allow an `interval` option.

Example :
```yaml
security:
  firewalls:
    main:
       login_throttling:
           max_attempts: 5
           interval: '15 minutes'
```

See functional tests.

🤷🏻‍♂️  This pull-request is a copy of [this pull-request ](#39927) that I've created some weeks ago. On the original PR, I just needed to rebase on 5.x to pass the tests (fabbot etc.) but the rebase I've tried runs in a loop of conflicts and I'm stuck. I've never experienced this before... SORRY.

Commits
-------

d1a0342 Fix tests
cc74095 changes rebased
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants