summaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-03-22 19:05:38 +0100
committerGravatar GitHub <noreply@github.com> 2019-03-22 19:05:38 +0100
commitebd8c31c0272f135b1b55f0480d1c8c3875935fe (patch)
tree829ce65bd8c6bc26ad1946dd08215eb3161ad19f /app/Controllers
parente84a90943ab1e4a254b2d33c7cabef18b718b456 (diff)
Rework CSRF interaction with sessions (#2290)
* Rework CSRF interaction with sessions Fix https://github.com/FreshRSS/FreshRSS/issues/2288 Improve security in some edge cases Maybe relevant for https://github.com/FreshRSS/FreshRSS/issues/2125#issuecomment-474992671 * Forgotten mime type
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/authController.php6
-rw-r--r--app/Controllers/userController.php1
2 files changed, 6 insertions, 1 deletions
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php
index 75d4acae0..ca44b1a96 100644
--- a/app/Controllers/authController.php
+++ b/app/Controllers/authController.php
@@ -69,7 +69,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
* the user is already connected.
*/
public function loginAction() {
- if (FreshRSS_Auth::hasAccess()) {
+ if (FreshRSS_Auth::hasAccess() && Minz_Request::param('u', '') == '') {
Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);
}
@@ -133,6 +133,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
// Set session parameter to give access to the user.
Minz_Session::_param('currentUser', $username);
Minz_Session::_param('passwordHash', $conf->passwordHash);
+ Minz_Session::_param('csrf');
FreshRSS_Auth::giveAccess();
// Set cookie parameter if nedded.
@@ -161,6 +162,8 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
return;
}
+ FreshRSS_FormAuth::deleteCookie();
+
$conf = get_user_configuration($username);
if ($conf == null) {
return;
@@ -176,6 +179,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
if ($ok) {
Minz_Session::_param('currentUser', $username);
Minz_Session::_param('passwordHash', $s);
+ Minz_Session::_param('csrf');
FreshRSS_Auth::giveAccess();
Minz_Request::good(_t('feedback.auth.login.success'),
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index 71172b9ef..be3787561 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -247,6 +247,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$user_conf = get_user_configuration($new_user_name);
Minz_Session::_param('currentUser', $new_user_name);
Minz_Session::_param('passwordHash', $user_conf->passwordHash);
+ Minz_Session::_param('csrf');
FreshRSS_Auth::giveAccess();
}