Skip to content
Snippets Groups Projects
Unverified Commit cdf01feb authored by Bjoern Schiessle's avatar Bjoern Schiessle
Browse files

add action to existing brute force protection

parent 0271ae3b
No related branches found
No related tags found
No related merge requests found
...@@ -205,8 +205,8 @@ class LoginController extends Controller { ...@@ -205,8 +205,8 @@ class LoginController extends Controller {
* @return RedirectResponse * @return RedirectResponse
*/ */
public function tryLogin($user, $password, $redirect_url, $remember_login = false, $timezone = '', $timezone_offset = '') { public function tryLogin($user, $password, $redirect_url, $remember_login = false, $timezone = '', $timezone_offset = '') {
$currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress()); $currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress(), 'login');
$this->throttler->sleepDelay($this->request->getRemoteAddress()); $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'login');
// If the user is already logged in and the CSRF check does not pass then // If the user is already logged in and the CSRF check does not pass then
// simply redirect the user to the correct page as required. This is the // simply redirect the user to the correct page as required. This is the
...@@ -230,7 +230,7 @@ class LoginController extends Controller { ...@@ -230,7 +230,7 @@ class LoginController extends Controller {
if ($loginResult === false) { if ($loginResult === false) {
$this->throttler->registerAttempt('login', $this->request->getRemoteAddress(), ['user' => $originalUser]); $this->throttler->registerAttempt('login', $this->request->getRemoteAddress(), ['user' => $originalUser]);
if($currentDelay === 0) { if($currentDelay === 0) {
$this->throttler->sleepDelay($this->request->getRemoteAddress()); $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'login');
} }
$this->session->set('loginMessages', [ $this->session->set('loginMessages', [
['invalidpassword'], [] ['invalidpassword'], []
...@@ -295,15 +295,15 @@ class LoginController extends Controller { ...@@ -295,15 +295,15 @@ class LoginController extends Controller {
* @return DataResponse * @return DataResponse
*/ */
public function confirmPassword($password) { public function confirmPassword($password) {
$currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress()); $currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress(), 'sudo');
$this->throttler->sleepDelay($this->request->getRemoteAddress()); $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'sudo');
$loginName = $this->userSession->getLoginName(); $loginName = $this->userSession->getLoginName();
$loginResult = $this->userManager->checkPassword($loginName, $password); $loginResult = $this->userManager->checkPassword($loginName, $password);
if ($loginResult === false) { if ($loginResult === false) {
$this->throttler->registerAttempt('sudo', $this->request->getRemoteAddress(), ['user' => $loginName]); $this->throttler->registerAttempt('sudo', $this->request->getRemoteAddress(), ['user' => $loginName]);
if ($currentDelay === 0) { if ($currentDelay === 0) {
$this->throttler->sleepDelay($this->request->getRemoteAddress()); $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'sudo');
} }
return new DataResponse([], Http::STATUS_FORBIDDEN); return new DataResponse([], Http::STATUS_FORBIDDEN);
......
...@@ -128,7 +128,7 @@ class OCSController extends \OCP\AppFramework\OCSController { ...@@ -128,7 +128,7 @@ class OCSController extends \OCP\AppFramework\OCSController {
*/ */
public function personCheck($login = '', $password = '') { public function personCheck($login = '', $password = '') {
if ($login !== '' && $password !== '') { if ($login !== '' && $password !== '') {
$this->throttler->sleepDelay($this->request->getRemoteAddress()); $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'login');
if ($this->userManager->checkPassword($login, $password)) { if ($this->userManager->checkPassword($login, $password)) {
return new DataResponse([ return new DataResponse([
'person' => [ 'person' => [
......
...@@ -317,7 +317,7 @@ class Session implements IUserSession, Emitter { ...@@ -317,7 +317,7 @@ class Session implements IUserSession, Emitter {
$password, $password,
IRequest $request, IRequest $request,
OC\Security\Bruteforce\Throttler $throttler) { OC\Security\Bruteforce\Throttler $throttler) {
$currentDelay = $throttler->sleepDelay($request->getRemoteAddress()); $currentDelay = $throttler->sleepDelay($request->getRemoteAddress(), 'login');
$isTokenPassword = $this->isTokenPassword($password); $isTokenPassword = $this->isTokenPassword($password);
if (!$isTokenPassword && $this->isTokenAuthEnforced()) { if (!$isTokenPassword && $this->isTokenAuthEnforced()) {
...@@ -334,7 +334,7 @@ class Session implements IUserSession, Emitter { ...@@ -334,7 +334,7 @@ class Session implements IUserSession, Emitter {
$throttler->registerAttempt('login', $request->getRemoteAddress(), ['uid' => $user]); $throttler->registerAttempt('login', $request->getRemoteAddress(), ['uid' => $user]);
if($currentDelay === 0) { if($currentDelay === 0) {
$throttler->sleepDelay($request->getRemoteAddress()); $throttler->sleepDelay($request->getRemoteAddress(), 'login');
} }
return false; return false;
} }
...@@ -768,7 +768,7 @@ class Session implements IUserSession, Emitter { ...@@ -768,7 +768,7 @@ class Session implements IUserSession, Emitter {
try { try {
$this->tokenProvider->invalidateToken($this->session->getId()); $this->tokenProvider->invalidateToken($this->session->getId());
} catch (SessionNotAvailableException $ex) { } catch (SessionNotAvailableException $ex) {
} }
} }
$this->setUser(null); $this->setUser(null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment