- Added configuration entry authentication_logout_page in auth.php

- Fixed function cleanSessionElement in hlp_session_helper
- Added constants AUTHENTICATION_LOGOUT_PAGE and SESSION_LANDING_PAGE to AuthLib
- Fixed method loginLDAP in AuthLib
- Added public method redirectToLandingPage to AuthLib
- Renamed method _storeAuthObj to _storeSessionAuthObj in AuthLib
- Added private method _storeSessionLandingPage to AuthLib
- Added private method _redirectTemporarily to AuthLib
This commit is contained in:
Paolo
2019-03-14 13:31:07 +01:00
parent 3494c7a2ef
commit 4c2b1731a7
5 changed files with 71 additions and 28 deletions
+3
View File
@@ -16,3 +16,6 @@ $config['authentication_login_pages'] = array(
AUTH_LDAP => '/system/Login/usernamePassword',
AUTH_SSO => '/system/Login/sso'
);
// Logout page
$config['authentication_logout_page'] = '/system/Logout';
@@ -1,19 +1,6 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
if (! defined('BASEPATH'))
exit('No direct script access allowed');
if (! defined('BASEPATH')) exit('No direct script access allowed');
class ReihungstestJob extends FHC_Controller
{
@@ -38,7 +25,7 @@ class ReihungstestJob extends FHC_Controller
exit;
}
$this->VILESCI_RT_VERWALTUNGS_URL = site_url(). "/organisation/Reihungstest";
$this->VILESCI_RT_VERWALTUNGS_URL = site_url('/organisation/Reihungstest');
// Load models
$this->load->model('crm/Reihungstest_model', 'ReihungstestModel');
+2 -4
View File
@@ -90,10 +90,8 @@ function cleanSession($sessionName)
*/
function cleanSessionElement($sessionName, $elementName)
{
$session = getSession($sessionName); // get the whole session with the given name
if (isset($session[$elementName]))
if (isset($_SESSION[$sessionName][$elementName]))
{
unset($session[$elementName]);
unset($_SESSION[$sessionName][$elementName]);
}
}
+63 -8
View File
@@ -11,6 +11,7 @@ class AuthLib
const AUTHENTICATION_FOREIGN_METHODS = 'authentication_foreign_methods';
const AUTHENTICATION_LOGIN = 'authentication_login';
const AUTHENTICATION_LOGIN_PAGES = 'authentication_login_pages';
const AUTHENTICATION_LOGOUT_PAGE = 'authentication_logout_page';
// Login object properties
const AO_PERSON_ID = 'person_id';
@@ -22,6 +23,7 @@ class AuthLib
const SESSION_NAME = 'AUTH';
const SESSION_AUTH_OBJ = 'AUTH_OBJ';
const SESSION_AUTH_OBJ_ORIGIN = 'AUTH_OBJ_ORIGIN';
const SESSION_LANDING_PAGE = 'LANDING_PAGE';
private $_ci; // CI instance
@@ -125,12 +127,38 @@ class AuthLib
// If were possible to retrieve user's data without failing,
// then stores the authentication object into authentication session
if (isSuccess($loginUP)) $this->_storeAuthObj(getData($loginUP));
if (isSuccess($loginUP)) $this->_storeSessionAuthObj(getData($loginUP));
}
return $loginUP;
}
/**
* Redirect to the previously stored landing page
*/
public function redirectToLandingPage($altLandingPage = null)
{
// Tries to get the previously stored landing page
$landingPage = getSessionElement(self::SESSION_NAME, self::SESSION_LANDING_PAGE);
if ($landingPage == null) // if not present
{
// If it was given a valid alternative landing page
if (!isEmptyString($altLandingPage))
{
$landingPage = $altLandingPage;
}
else
{
$landingPage = site_url(); // use the default home page
}
}
// Clean the previously stored landing page
cleanSessionElement(self::SESSION_NAME, self::SESSION_LANDING_PAGE);
$this->_redirectTemporarily($landingPage); // redirect to landing page
}
/**
* Checks the authentication of an addon. Returns TRUE if valid, otherwise FALSE
*/
@@ -380,26 +408,42 @@ class AuthLib
/**
* Stores the authentication object into the authentication session
*/
private function _storeAuthObj($authObj)
private function _storeSessionAuthObj($authObj)
{
setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ, $authObj); // authentication object
setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ_ORIGIN, $authObj); // authentication original object
}
/**
* Stores the user accessed point into the authentication session
*/
private function _storeSessionLandingPage($loginPage, $logoutPage)
{
// Build the curret URL (user access point)
$currentURL = current_url().(!isEmptyString($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : '');
// If the access point is not the login page or the logout page
if ($currentURL != site_url($loginPage) && $currentURL != site_url($logoutPage))
{
setSessionElement(self::SESSION_NAME, self::SESSION_LANDING_PAGE, $currentURL);
}
}
/**
* Redirect the user's browser to the configured login page
*/
private function _redirectToLogin()
{
$al = $this->_ci->config->item(self::AUTHENTICATION_LOGIN); // selected login method
$alp = $this->_ci->config->item(self::AUTHENTICATION_LOGIN_PAGES); // login pages configuration array
$alip = $this->_ci->config->item(self::AUTHENTICATION_LOGIN_PAGES); // login pages configuration array
$alop = $this->_ci->config->item(self::AUTHENTICATION_LOGOUT_PAGE); // logout page configuration
// If the configuration is valid
if (!isEmptyArray($alp) && isset($alp[$al]))
if (!isEmptyArray($alip) && isset($alip[$al]))
{
header('HTTP/1.1 302 Moved temporary'); // temporary redirection
header('Location: '.site_url().$alp[$al]); // redirect to the configured login page
exit(); // stops execution!
$this->_storeSessionLandingPage($alip[$al], $alop); // stores in session the user access point
$this->_redirectTemporarily(site_url($alip[$al])); // redirect to login page
}
else
{
@@ -421,7 +465,7 @@ class AuthLib
$auth = $this->_checkForeignAuthentication();
if (hasData($auth)) // Authenticated with a foreign authentication method
{
$this->_storeAuthObj(getData($auth)); // store the session authentication object
$this->_storeSessionAuthObj(getData($auth)); // store the session authentication object
}
elseif (getCode($auth) == AUTH_NOT_AUTHENTICATED) // if no foreign authentication was found...
{
@@ -473,6 +517,17 @@ class AuthLib
return $authObj;
}
/**
* HTTP temporary redirection
*/
private function _redirectTemporarily($url)
{
// Temporary redirection
header('HTTP/1.1 302 Moved temporary');
header('Location: '.$url); // redirect to the given URL
exit(); // stops execution!
}
/**
* Returns all the keys with which is possible to obtain personal data about a final user
* using the given username (uid)
@@ -15,7 +15,7 @@ $this->load->view(
?>
<body>
<?php
$href = site_url().'/ViewMessage/sendReply';
$href = site_url('/ViewMessage/sendReply');
?>
<div id="wrapper">
<div id="page-wrapper">