diff --git a/application/config/constants.php b/application/config/constants.php index 76631502c..5e0c9e66e 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -20,6 +20,52 @@ define('FHC_NORIGHT', 5); // No rights define('FHC_INVALIDID', 6); // Invalid or no ID (key) define('FHC_NOPK', 7); // No primary key +/* +|-------------------------------------------------------------------------- +| Exit status codes +|-------------------------------------------------------------------------- +| +| Used to indicate the conditions under which the script is exit()ing. +| While there is no universal standard for error codes, there are some +| broad conventions. Three such conventions are mentioned below, for +| those who wish to make use of them. The CodeIgniter defaults were +| chosen for the least overlap with these conventions, while still +| leaving room for others to be defined in future versions and user +| applications. +| +*/ +define('EXIT_SUCCESS', 0); // no errors +define('EXIT_ERROR', 1); // generic error +define('EXIT_MODEL', 2); // model error +define('EXIT_CONFIG', 3); // configuration error +define('EXIT_UNKNOWN_FILE', 4); // file not found +define('EXIT_UNKNOWN_CLASS', 5); // unknown class +define('EXIT_UNKNOWN_METHOD', 6); // unknown class member +define('EXIT_USER_INPUT', 7); // invalid user input +define('EXIT_DATABASE', 8); // database error +define('EXIT_VALIDATION_UDF', 10); // UDF validation has been failed +define('EXIT_VALIDATION_UDF_MIN_VALUE', 11); // UDF validation has been failed -> MIN VALUE +define('EXIT_VALIDATION_UDF_MAX_VALUE', 12); // UDF validation has been failed -> MAX VALUE +define('EXIT_VALIDATION_UDF_MIN_LENGTH', 13); // UDF validation has been failed -> MIN LENGTH +define('EXIT_VALIDATION_UDF_MAX_LENGTH', 14); // UDF validation has been failed -> MAX LENGTH +define('EXIT_VALIDATION_UDF_REGEX', 15); // UDF validation has been failed -> REGEX +define('EXIT_VALIDATION_UDF_REQUIRED', 16); // UDF validation has been failed -> REQUIRED +define('EXIT_VALIDATION_UDF_NOT_VALID_VAL', 17); // UDF validation has been failed -> Not valid value, object or array + +define('EXIT_AUTO_MIN', 1000); // lowest automatically-assigned error code +define('EXIT_AUTO_MAX', 2000); // highest automatically-assigned error code + +/* +|-------------------------------------------------------------------------- +| Authentication constants +|-------------------------------------------------------------------------- +*/ +// Authentication methods +define('AUTH_SESSION', 'session'); +define('AUTH_LDAP', 'ldap'); +define('AUTH_DB', 'database'); +define('AUTH_SSO', 'sso'); + /* |-------------------------------------------------------------------------- | File and directory modes @@ -67,41 +113,6 @@ define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b'); */ define('SHOW_DEBUG_BACKTRACE', TRUE); -/* -|-------------------------------------------------------------------------- -| Exit status codes -|-------------------------------------------------------------------------- -| -| Used to indicate the conditions under which the script is exit()ing. -| While there is no universal standard for error codes, there are some -| broad conventions. Three such conventions are mentioned below, for -| those who wish to make use of them. The CodeIgniter defaults were -| chosen for the least overlap with these conventions, while still -| leaving room for others to be defined in future versions and user -| applications. -| -*/ -define('EXIT_SUCCESS', 0); // no errors -define('EXIT_ERROR', 1); // generic error -define('EXIT_MODEL', 2); // model error -define('EXIT_CONFIG', 3); // configuration error -define('EXIT_UNKNOWN_FILE', 4); // file not found -define('EXIT_UNKNOWN_CLASS', 5); // unknown class -define('EXIT_UNKNOWN_METHOD', 6); // unknown class member -define('EXIT_USER_INPUT', 7); // invalid user input -define('EXIT_DATABASE', 8); // database error -define('EXIT_VALIDATION_UDF', 10); // UDF validation has been failed -define('EXIT_VALIDATION_UDF_MIN_VALUE', 11); // UDF validation has been failed -> MIN VALUE -define('EXIT_VALIDATION_UDF_MAX_VALUE', 12); // UDF validation has been failed -> MAX VALUE -define('EXIT_VALIDATION_UDF_MIN_LENGTH', 13); // UDF validation has been failed -> MIN LENGTH -define('EXIT_VALIDATION_UDF_MAX_LENGTH', 14); // UDF validation has been failed -> MAX LENGTH -define('EXIT_VALIDATION_UDF_REGEX', 15); // UDF validation has been failed -> REGEX -define('EXIT_VALIDATION_UDF_REQUIRED', 16); // UDF validation has been failed -> REQUIRED -define('EXIT_VALIDATION_UDF_NOT_VALID_VAL', 17); // UDF validation has been failed -> Not valid value, object or array - -define('EXIT_AUTO_MIN', 1000); // lowest automatically-assigned error code -define('EXIT_AUTO_MAX', 2000); // highest automatically-assigned error code - /* |-------------------------------------------------------------------------- | Email constants diff --git a/application/controllers/api/v1/CheckUserAuth.php b/application/controllers/api/v1/CheckUserAuth.php index 181c68ca1..d9d6cb1a8 100644 --- a/application/controllers/api/v1/CheckUserAuth.php +++ b/application/controllers/api/v1/CheckUserAuth.php @@ -1,21 +1,7 @@ load->helper('hlp_message'); } /** @@ -36,7 +26,7 @@ class CheckUserAuth extends REST_Controller if (isset($username) && isset($password)) { - $result = $this->authlib->CheckUserAuthByUsernamePassword($username, $password); + $result = $this->authlib->checkUserAuthByUsernamePassword($username, $password); $this->response($result, REST_Controller::HTTP_OK); } @@ -63,18 +53,18 @@ class CheckUserAuth extends REST_Controller // If username and password are given then check authentication using them if (isset($username) && isset($password)) { - $result = $this->authlib->CheckUserAuthByUsernamePassword($username, $password, true); + $result = $this->authlib->checkUserAuthByUsernamePassword($username, $password, true); } elseif (isset($code) || isset($email)) { // If code and email are given then check authentication using them if (isset($code) && isset($email)) { - $result = $this->authlib->CheckUserAuthByCodeEmail($code, $email); + $result = $this->authlib->checkUserAuthByCodeEmail($code, $email); } else // otherwise check authentication using only code { - $result = $this->authlib->CheckUserAuthByCode($code); + $result = $this->authlib->checkUserAuthByCode($code); } } diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php index b2cd98051..1efbe5600 100644 --- a/application/core/APIv1_Controller.php +++ b/application/core/APIv1_Controller.php @@ -1,7 +1,5 @@ config->item('auth_library_class')); - $auth_library_function = strtolower($this->config->item('auth_library_function')); + $auth_library_class = $this->config->item('auth_library_class'); + $auth_library_function = $this->config->item('auth_library_function'); if (empty($auth_library_class)) { @@ -1814,15 +1814,12 @@ abstract class REST_Controller extends CI_Controller { return FALSE; } - // Loads authentication library - $this->load->library('AuthLib'); - if (is_callable([$auth_library_class, $auth_library_function]) === FALSE) { - $this->load->library($auth_library_class); + $this->load->library($auth_library_class, array(false)); } - return $this->{$auth_library_class}->$auth_library_function($username, $password); + return $this->{strtolower($auth_library_class)}->$auth_library_function($username, $password); } /** diff --git a/application/helpers/hlp_authentication_helper.php b/application/helpers/hlp_authentication_helper.php index dd25b2a38..abf85a7a3 100644 --- a/application/helpers/hlp_authentication_helper.php +++ b/application/helpers/hlp_authentication_helper.php @@ -1,61 +1,22 @@ checkpassword($username, $password)) - { - echo 'Auth-Method-False'; - return true; - } - else - { - echo 'Auth-Method-False'; - return false; - } - } -} - /** - * Look if User is logged in and return uid - * it tries to work always with CI session - * Otherwise return false + * It calls the AuthLib, if the user is NOT logged then the login page is shown + * If the user is alredy logged, then it is possible to access to the authentication object + * that contains the username of the logged user * - * @return string or (bool)false -*/ + * @return string or null + */ function getAuthUID() { $ci =& get_instance(); // get CI instance $ci->load->library('AuthLib'); // load authentication library - return $ci->authlib->getUser(); + return ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME}; } diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index 980598d9b..ae68837f8 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -65,7 +65,7 @@ class PermissionLib { // API Caller rights initialization self::$bb = new benutzerberechtigung(); - self::$bb->getBerechtigungen($this->_ci->authlib->getUser()); + self::$bb->getBerechtigungen(($this->_ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME}); } }