LSauthMethods : use LSlog_logger

This commit is contained in:
Benjamin Renard 2020-05-08 15:49:36 +02:00
parent 77144a21d0
commit cc288cc391
3 changed files with 16 additions and 14 deletions

View file

@ -20,12 +20,14 @@
******************************************************************************/ ******************************************************************************/
LSsession :: loadLSclass('LSlog_staticLoggerClass');
/** /**
* Base of a authentication provider for LSauth * Base of a authentication provider for LSauth
* *
* @author Benjamin Renard <brenard@easter-eggs.com> * @author Benjamin Renard <brenard@easter-eggs.com>
*/ */
class LSauthMethod { class LSauthMethod extends LSlog_staticLoggerClass {
var $authData = array(); var $authData = array();
@ -33,9 +35,9 @@ class LSauthMethod {
// Load config (without warning if not found) // Load config (without warning if not found)
$conf_file = LS_CONF_DIR."LSauth/config.".get_class($this).".php"; $conf_file = LS_CONF_DIR."LSauth/config.".get_class($this).".php";
if (LSsession :: includeFile($conf_file, false, false)) if (LSsession :: includeFile($conf_file, false, false))
LSlog :: debug(get_class($this)." :: __construct(): config file ($conf_file) loaded"); self :: log_debug(get_class($this)." :: __construct(): config file ($conf_file) loaded");
else else
LSlog :: debug(get_class($this)." :: __construct(): config file ($conf_file) not found"); self :: log_debug(get_class($this)." :: __construct(): config file ($conf_file) not found");
return true; return true;
} }

View file

@ -38,10 +38,10 @@ class LSauthMethod_CAS extends LSauthMethod {
if (LSsession :: includeFile(PHP_CAS_PATH, true)) { if (LSsession :: includeFile(PHP_CAS_PATH, true)) {
if (defined('PHP_CAS_DEBUG_FILE')) { if (defined('PHP_CAS_DEBUG_FILE')) {
LSlog :: debug('LSauthMethod_CAS : enable debug file '.PHP_CAS_DEBUG_FILE); self :: log_debug('LSauthMethod_CAS : enable debug file '.PHP_CAS_DEBUG_FILE);
phpCAS::setDebug(PHP_CAS_DEBUG_FILE); phpCAS::setDebug(PHP_CAS_DEBUG_FILE);
} }
LSlog :: debug('LSauthMethod_CAS : initialise phpCAS :: client with CAS server URL https://'.LSAUTH_CAS_SERVER_HOSTNAME.':'.LSAUTH_CAS_SERVER_PORT.(defined('LSAUTH_CAS_SERVER_URI')?LSAUTH_CAS_SERVER_URI: '')); self :: log_debug('LSauthMethod_CAS : initialise phpCAS :: client with CAS server URL https://'.LSAUTH_CAS_SERVER_HOSTNAME.':'.LSAUTH_CAS_SERVER_PORT.(defined('LSAUTH_CAS_SERVER_URI')?LSAUTH_CAS_SERVER_URI: ''));
phpCAS::client ( phpCAS::client (
constant(LSAUTH_CAS_VERSION), constant(LSAUTH_CAS_VERSION),
LSAUTH_CAS_SERVER_HOSTNAME, LSAUTH_CAS_SERVER_HOSTNAME,
@ -53,13 +53,13 @@ class LSauthMethod_CAS extends LSauthMethod {
// Configure CAS server SSL validation // Configure CAS server SSL validation
$cas_server_ssl_validation_configured = false; $cas_server_ssl_validation_configured = false;
if (defined('LSAUTH_CAS_SERVER_NO_SSL_VALIDATION') && LSAUTH_CAS_SERVER_NO_SSL_VALIDATION) { if (defined('LSAUTH_CAS_SERVER_NO_SSL_VALIDATION') && LSAUTH_CAS_SERVER_NO_SSL_VALIDATION) {
LSlog :: debug('LSauthMethod_CAS : disable CAS server SSL validation => /!\ NOT RECOMMENDED IN PRODUCTION ENVIRONMENT /!\\'); self :: log_debug('LSauthMethod_CAS : disable CAS server SSL validation => /!\ NOT RECOMMENDED IN PRODUCTION ENVIRONMENT /!\\');
phpCAS::setNoCasServerValidation(); phpCAS::setNoCasServerValidation();
$cas_server_ssl_validation_configured = true; $cas_server_ssl_validation_configured = true;
} }
if (defined('LSAUTH_CAS_SERVER_SSL_CACERT')) { if (defined('LSAUTH_CAS_SERVER_SSL_CACERT')) {
LSlog :: debug('LSauthMethod_CAS : validate CAS server SSL certificate using '.LSAUTH_CAS_SERVER_SSL_CACERT.' CA certificate file.'); self :: log_debug('LSauthMethod_CAS : validate CAS server SSL certificate using '.LSAUTH_CAS_SERVER_SSL_CACERT.' CA certificate file.');
phpCAS::setCasServerCACert(LSAUTH_CAS_SERVER_SSL_CACERT); phpCAS::setCasServerCACert(LSAUTH_CAS_SERVER_SSL_CACERT);
$cas_server_ssl_validation_configured = true; $cas_server_ssl_validation_configured = true;
} }
@ -71,12 +71,12 @@ class LSauthMethod_CAS extends LSauthMethod {
} }
if (defined('LSAUTH_CAS_CURL_SSLVERION')) { if (defined('LSAUTH_CAS_CURL_SSLVERION')) {
LSlog :: debug('LSauthMethod_CAS : use specific SSL version '.LSAUTH_CAS_CURL_SSLVERION); self :: log_debug('LSauthMethod_CAS : use specific SSL version '.LSAUTH_CAS_CURL_SSLVERION);
phpCAS::setExtraCurlOption(CURLOPT_SSLVERSION,LSAUTH_CAS_CURL_SSLVERION); phpCAS::setExtraCurlOption(CURLOPT_SSLVERSION,LSAUTH_CAS_CURL_SSLVERION);
} }
if (LSAUTH_CAS_DISABLE_LOGOUT) { if (LSAUTH_CAS_DISABLE_LOGOUT) {
LSlog :: debug('LSauthMethod_CAS : disable logout'); self :: log_debug('LSauthMethod_CAS : disable logout');
LSauth :: disableLogoutBtn(); LSauth :: disableLogoutBtn();
} }
@ -100,13 +100,13 @@ class LSauthMethod_CAS extends LSauthMethod {
public function getAuthData() { public function getAuthData() {
if ($this -> configured) { if ($this -> configured) {
// Launch Auth // Launch Auth
LSlog :: debug('LSauthMethod_CAS : force authentication'); self :: log_debug('LSauthMethod_CAS : force authentication');
phpCAS::forceAuthentication(); phpCAS::forceAuthentication();
$this -> authData = array( $this -> authData = array(
'username' => phpCAS::getUser() 'username' => phpCAS::getUser()
); );
LSlog :: debug('LSauthMethod_CAS : auth data : '.varDump($this -> authData)); self :: log_debug('LSauthMethod_CAS : auth data : '.varDump($this -> authData));
return $this -> authData; return $this -> authData;
} }
return; return;
@ -121,12 +121,12 @@ class LSauthMethod_CAS extends LSauthMethod {
if($this -> configured) { if($this -> configured) {
if (LSauth :: displayLogoutBtn()) { if (LSauth :: displayLogoutBtn()) {
phpCAS :: forceAuthentication(); phpCAS :: forceAuthentication();
LSlog :: debug("LSauthMethod_CAS :: logout() : trigger CAS logout"); self :: log_debug("LSauthMethod_CAS :: logout() : trigger CAS logout");
phpCAS :: logout(); phpCAS :: logout();
return true; return true;
} }
else else
LSlog :: warning("LSauthMethod_CAS :: logout() : logout is disabled"); self :: log_warning("LSauthMethod_CAS :: logout() : logout is disabled");
} }
return; return;
} }

View file

@ -35,7 +35,7 @@ class LSauthMethod_anonymous extends LSauthMethod {
return; return;
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT')) || (constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT') === True)) { if ( (!defined('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT')) || (constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT') === True)) {
LSlog :: debug('logout : '.constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT')); self :: log_debug('logout : '.constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT'));
LSauth :: disableLogoutBtn(); LSauth :: disableLogoutBtn();
} }