-
Notifications
You must be signed in to change notification settings - Fork 76
Add custom period of blocking time #70
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
Open
yurka44
wants to merge
25
commits into
jaytaph:main
Choose a base branch
from
JivoChat:jivosite/custom-period-of-lock
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4dcf52d
Add block period into annotation
sane4ek-2 e858246
Add an ability to get block period from config file
sane4ek-2 f70c74d
Add predis/predis package for development
sane4ek-2 b52562d
Add block status into RateLimitInfo
sane4ek-2 c39d49f
Add the key of rate limit into RateLimitInfo
sane4ek-2 8a7b7b2
Add setting of block into all available storages
sane4ek-2 ec310dd
Fix test
sane4ek-2 ed27380
Change set block method of mock storage
sane4ek-2 86d4a20
Add calling of setBlock method of storages into rate limit service
sane4ek-2 28de195
Add passing blocked value of rate limit from a storage into the object
sane4ek-2 6d8a4d9
Add an ability of setting custom period of time of blocking a call
sane4ek-2 a00ca57
Add a new event is dispatched after a block happened
sane4ek-2 4ba74d2
Add comment for generate key event
sane4ek-2 52b0549
Add firing block event when block happens
sane4ek-2 f589268
Add dispatching an event before sending a response
sane4ek-2 8896661
Add information about new feature block_period
sane4ek-2 dbea0dc
Rename constant of an event ratelimit.block.after
sane4ek-2 65dbbf5
Add documentation and examples about events
sane4ek-2 067dac3
Fix missing of setting key value into RateLimitInfo
sane4ek-2 a957440
Resolve conflicts between master and jivosite/custom-period-of-lock
sane4ek-2 bc6e1bb
Add block method into PsrCache storage
sane4ek-2 02b460d
Add block method into SimpleCache storage
sane4ek-2 59a7c85
Fix new tests
sane4ek-2 630b1d1
Fix tests
sane4ek-2 4b73007
Fix the last test
sane4ek-2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Noxlogic\RateLimitBundle\Events; | ||
|
||
use Noxlogic\RateLimitBundle\Service\RateLimitInfo; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class BlockEvent extends Event | ||
{ | ||
/** | ||
* @var RateLimitInfo | ||
*/ | ||
private $rateLimitInfo; | ||
|
||
/** | ||
* @var Request | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* BlockEvent constructor. | ||
* | ||
* @param RateLimitInfo $rateLimitInfo | ||
* @param Request $request | ||
*/ | ||
public function __construct(RateLimitInfo $rateLimitInfo, Request $request) | ||
{ | ||
$this->rateLimitInfo = $rateLimitInfo; | ||
$this->request = $request; | ||
} | ||
|
||
|
||
/** | ||
* @return RateLimitInfo | ||
*/ | ||
public function getRateLimitInfo() | ||
{ | ||
return $this->rateLimitInfo; | ||
} | ||
|
||
/** | ||
* @return Request | ||
*/ | ||
public function getRequest() | ||
{ | ||
return $this->request; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Noxlogic\RateLimitBundle\Events; | ||
|
||
use Noxlogic\RateLimitBundle\Service\RateLimitInfo; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class GetResponseEvent extends Event | ||
{ | ||
/** | ||
* @var Response | ||
*/ | ||
private $response; | ||
|
||
/** | ||
* @var Request | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* @var RateLimitInfo | ||
*/ | ||
private $rateLimitInfo; | ||
|
||
/** | ||
* GetResponseEvent constructor. | ||
* | ||
* @param Request $request | ||
* @param RateLimitInfo $rateLimitInfo | ||
*/ | ||
public function __construct(Request $request, RateLimitInfo $rateLimitInfo) | ||
{ | ||
$this->request = $request; | ||
$this->rateLimitInfo = $rateLimitInfo; | ||
} | ||
|
||
|
||
/** | ||
* @return Response | ||
*/ | ||
public function getResponse() | ||
{ | ||
return $this->response; | ||
} | ||
|
||
/** | ||
* @param Response $response | ||
*/ | ||
public function setResponse(Response $response) | ||
{ | ||
$this->response = $response; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function hasResponse() | ||
{ | ||
return null !== $this->response; | ||
} | ||
|
||
/** | ||
* @return Request | ||
*/ | ||
public function getRequest() | ||
{ | ||
return $this->request; | ||
} | ||
|
||
/** | ||
* @return RateLimitInfo | ||
*/ | ||
public function getRateLimitInfo() | ||
{ | ||
return $this->rateLimitInfo; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think If the block period isn't set, there should be no extended block period, as in how system works at the moment.