mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 08:22:17 +00:00
- Moved REST_Controller from libraries to core directory
- Changed the relatives includes - Changed the controller api/v1/CheckUserAuth to be adapted to the AuthLib changes - Removed function auth from helpers/hlp_authentication_helper - Adapted function getAuthUID of helpers/hlp_authentication_helper to the AuthLib changes - Adapted constructor of PermissionLib to the AuthLib changes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
<?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');
|
||||
|
||||
require_once APPPATH.'/libraries/REST_Controller.php';
|
||||
|
||||
class CheckUserAuth extends REST_Controller
|
||||
{
|
||||
/**
|
||||
@@ -24,6 +10,10 @@ class CheckUserAuth extends REST_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
// NOTE: loaded here because it does not extend the APIv1_Controller
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once APPPATH.'/libraries/REST_Controller.php';
|
||||
|
||||
class APIv1_Controller extends REST_Controller
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -1799,8 +1799,8 @@ abstract class REST_Controller extends CI_Controller {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$auth_library_class = strtolower($this->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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,61 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-Helper
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2016 fhcomplete.org
|
||||
* @license GPLv3
|
||||
* @link https://fhcomplete.org
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once FHCPATH.'include/authentication.class.php';
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Functions needed to manage the user authentication
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('auth'))
|
||||
{
|
||||
/**
|
||||
* Auth Username, Password over FH-Complete
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
function auth($username, $password)
|
||||
{
|
||||
$auth = new authentication();
|
||||
if ($auth->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};
|
||||
}
|
||||
|
||||
@@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user