dont get bruteforce delay twice
This commit is contained in:
parent
3647fbe7cd
commit
6c93fe08f5
|
@ -225,8 +225,11 @@ class Throttler {
|
||||||
* Will sleep for the defined amount of time
|
* Will sleep for the defined amount of time
|
||||||
*
|
*
|
||||||
* @param string $ip
|
* @param string $ip
|
||||||
|
* @return int the time spent sleeping
|
||||||
*/
|
*/
|
||||||
public function sleepDelay($ip) {
|
public function sleepDelay($ip) {
|
||||||
usleep($this->getDelay($ip) * 1000);
|
$delay = $this->getDelay($ip);
|
||||||
|
usleep($delay * 1000);
|
||||||
|
return $delay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,8 +309,7 @@ class Session implements IUserSession, Emitter {
|
||||||
$password,
|
$password,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
OC\Security\Bruteforce\Throttler $throttler) {
|
OC\Security\Bruteforce\Throttler $throttler) {
|
||||||
$currentDelay = $throttler->getDelay($request->getRemoteAddress());
|
$currentDelay = $throttler->sleepDelay($request->getRemoteAddress());
|
||||||
$throttler->sleepDelay($request->getRemoteAddress());
|
|
||||||
|
|
||||||
$isTokenPassword = $this->isTokenPassword($password);
|
$isTokenPassword = $this->isTokenPassword($password);
|
||||||
if (!$isTokenPassword && $this->isTokenAuthEnforced()) {
|
if (!$isTokenPassword && $this->isTokenAuthEnforced()) {
|
||||||
|
|
|
@ -371,7 +371,7 @@ class SessionTest extends \Test\TestCase {
|
||||||
->with('token_auth_enforced', false)
|
->with('token_auth_enforced', false)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$request
|
$request
|
||||||
->expects($this->exactly(2))
|
->expects($this->any())
|
||||||
->method('getRemoteAddress')
|
->method('getRemoteAddress')
|
||||||
->willReturn('192.168.0.1');
|
->willReturn('192.168.0.1');
|
||||||
$this->throttler
|
$this->throttler
|
||||||
|
@ -379,7 +379,7 @@ class SessionTest extends \Test\TestCase {
|
||||||
->method('sleepDelay')
|
->method('sleepDelay')
|
||||||
->with('192.168.0.1');
|
->with('192.168.0.1');
|
||||||
$this->throttler
|
$this->throttler
|
||||||
->expects($this->once())
|
->expects($this->any())
|
||||||
->method('getDelay')
|
->method('getDelay')
|
||||||
->with('192.168.0.1')
|
->with('192.168.0.1')
|
||||||
->willReturn(0);
|
->willReturn(0);
|
||||||
|
@ -412,7 +412,7 @@ class SessionTest extends \Test\TestCase {
|
||||||
->method('set')
|
->method('set')
|
||||||
->with('app_password', 'I-AM-AN-APP-PASSWORD');
|
->with('app_password', 'I-AM-AN-APP-PASSWORD');
|
||||||
$request
|
$request
|
||||||
->expects($this->exactly(2))
|
->expects($this->any())
|
||||||
->method('getRemoteAddress')
|
->method('getRemoteAddress')
|
||||||
->willReturn('192.168.0.1');
|
->willReturn('192.168.0.1');
|
||||||
$this->throttler
|
$this->throttler
|
||||||
|
@ -420,7 +420,7 @@ class SessionTest extends \Test\TestCase {
|
||||||
->method('sleepDelay')
|
->method('sleepDelay')
|
||||||
->with('192.168.0.1');
|
->with('192.168.0.1');
|
||||||
$this->throttler
|
$this->throttler
|
||||||
->expects($this->once())
|
->expects($this->any())
|
||||||
->method('getDelay')
|
->method('getDelay')
|
||||||
->with('192.168.0.1')
|
->with('192.168.0.1')
|
||||||
->willReturn(0);
|
->willReturn(0);
|
||||||
|
@ -459,7 +459,7 @@ class SessionTest extends \Test\TestCase {
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
$request
|
$request
|
||||||
->expects($this->exactly(2))
|
->expects($this->any())
|
||||||
->method('getRemoteAddress')
|
->method('getRemoteAddress')
|
||||||
->willReturn('192.168.0.1');
|
->willReturn('192.168.0.1');
|
||||||
$this->throttler
|
$this->throttler
|
||||||
|
@ -467,7 +467,7 @@ class SessionTest extends \Test\TestCase {
|
||||||
->method('sleepDelay')
|
->method('sleepDelay')
|
||||||
->with('192.168.0.1');
|
->with('192.168.0.1');
|
||||||
$this->throttler
|
$this->throttler
|
||||||
->expects($this->once())
|
->expects($this->any())
|
||||||
->method('getDelay')
|
->method('getDelay')
|
||||||
->with('192.168.0.1')
|
->with('192.168.0.1')
|
||||||
->willReturn(0);
|
->willReturn(0);
|
||||||
|
|
Loading…
Reference in New Issue