aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/authController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-08-29 19:52:52 +0200
committerGravatar GitHub <noreply@github.com> 2016-08-29 19:52:52 +0200
commit17c8c039df675b3b0f8d88d14f7316a240eabe76 (patch)
tree3dd3da3e8f21b5e82905f756098b86e0d15b3935 /app/Controllers/authController.php
parent92d4ad32c9eb165dee6dc6d4b8cf510428dde9ec (diff)
parentaea7cd78367ef867cdac7082ac1e9f61c4de7e19 (diff)
Merge pull request #1233 from FreshRSS/dev1.5.0
Release 1.5.0
Diffstat (limited to 'app/Controllers/authController.php')
-rw-r--r--app/Controllers/authController.php152
1 files changed, 1 insertions, 151 deletions
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php
index f58b008de..9decba431 100644
--- a/app/Controllers/authController.php
+++ b/app/Controllers/authController.php
@@ -70,7 +70,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
/**
* This action handles the login page.
*
- * It forwards to the correct login page (form or Persona) or main page if
+ * It forwards to the correct login page (form) or main page if
* the user is already connected.
*/
public function loginAction() {
@@ -83,9 +83,6 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
case 'form':
Minz_Request::forward(array('c' => 'auth', 'a' => 'formLogin'));
break;
- case 'persona':
- Minz_Request::forward(array('c' => 'auth', 'a' => 'personaLogin'));
- break;
case 'http_auth':
case 'none':
// It should not happened!
@@ -189,81 +186,6 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
}
/**
- * This action handles Persona login page.
- *
- * If this action is reached through a POST request, assertion from Persona
- * is verificated and user connected if all is ok.
- *
- * Parameter is:
- * - assertion (default: false)
- *
- * @todo: Persona system should be moved to a plugin
- */
- public function personaLoginAction() {
- $this->view->res = false;
-
- if (Minz_Request::isPost()) {
- $this->view->_useLayout(false);
-
- $assert = Minz_Request::param('assertion');
- $url = 'https://verifier.login.persona.org/verify';
- $params = 'assertion=' . $assert . '&audience=' .
- urlencode(Minz_Url::display(null, 'php', true));
- $ch = curl_init();
- $options = array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => TRUE,
- CURLOPT_POST => 2,
- CURLOPT_POSTFIELDS => $params
- );
- curl_setopt_array($ch, $options);
- $result = curl_exec($ch);
- curl_close($ch);
-
- $res = json_decode($result, true);
-
- $login_ok = false;
- $reason = '';
- if ($res['status'] === 'okay') {
- $email = filter_var($res['email'], FILTER_VALIDATE_EMAIL);
- if ($email != '') {
- $persona_file = DATA_PATH . '/persona/' . $email . '.txt';
- if (($current_user = @file_get_contents($persona_file)) !== false) {
- $current_user = trim($current_user);
- $conf = get_user_configuration($current_user);
- if (!is_null($conf)) {
- $login_ok = strcasecmp($email, $conf->mail_login) === 0;
- } else {
- $reason = 'Invalid configuration for user ' .
- '[' . $current_user . ']';
- }
- }
- } else {
- $reason = 'Invalid email format [' . $res['email'] . ']';
- }
- } else {
- $reason = $res['reason'];
- }
-
- if ($login_ok) {
- Minz_Session::_param('currentUser', $current_user);
- Minz_Session::_param('mail', $email);
- FreshRSS_Auth::giveAccess();
- invalidateHttpCache();
- } else {
- Minz_Log::warning($reason);
-
- $res = array();
- $res['status'] = 'failure';
- $res['reason'] = _t('feedback.auth.login.invalid');
- }
-
- header('Content-Type: application/json; charset=UTF-8');
- $this->view->res = $res;
- }
- }
-
- /**
* This action removes all accesses of the current user.
*/
public function logoutAction() {
@@ -274,78 +196,6 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
}
/**
- * This action resets the authentication system.
- *
- * After reseting, form auth is set by default.
- */
- public function resetAction() {
- Minz_View::prependTitle(_t('admin.auth.title_reset') . ' ยท ');
-
- Minz_View::appendScript(Minz_Url::display(
- '/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js')
- ));
-
- $this->view->no_form = false;
- // Enable changement of auth only if Persona!
- if (FreshRSS_Context::$system_conf->auth_type != 'persona') {
- $this->view->message = array(
- 'status' => 'bad',
- 'title' => _t('gen.short.damn'),
- 'body' => _t('feedback.auth.not_persona')
- );
- $this->view->no_form = true;
- return;
- }
-
- $conf = get_user_configuration(FreshRSS_Context::$system_conf->default_user);
- if (is_null($conf)) {
- return;
- }
-
- // Admin user must have set its master password.
- if (!$conf->passwordHash) {
- $this->view->message = array(
- 'status' => 'bad',
- 'title' => _t('gen.short.damn'),
- 'body' => _t('feedback.auth.no_password_set')
- );
- $this->view->no_form = true;
- return;
- }
-
- invalidateHttpCache();
-
- if (Minz_Request::isPost()) {
- $nonce = Minz_Session::param('nonce');
- $username = Minz_Request::param('username', '');
- $challenge = Minz_Request::param('challenge', '');
-
- $ok = FreshRSS_FormAuth::checkCredentials(
- $username, $conf->passwordHash, $nonce, $challenge
- );
-
- if ($ok) {
- FreshRSS_Context::$system_conf->auth_type = 'form';
- $ok = FreshRSS_Context::$system_conf->save();
-
- if ($ok) {
- Minz_Request::good(_t('feedback.auth.form.set'));
- } else {
- Minz_Request::bad(_t('feedback.auth.form.not_set'),
- array('c' => 'auth', 'a' => 'reset'));
- }
- } else {
- Minz_Log::warning('Password mismatch for' .
- ' user=' . $username .
- ', nonce=' . $nonce .
- ', c=' . $challenge);
- Minz_Request::bad(_t('feedback.auth.login.invalid'),
- array('c' => 'auth', 'a' => 'reset'));
- }
- }
- }
-
- /**
* This action gives possibility to a user to create an account.
*/
public function registerAction() {