From 7032d8be7fffd600a3fa6be2ff357ded62e06081 Mon Sep 17 00:00:00 2001 From: paolo Date: Mon, 11 Apr 2016 17:23:51 +0200 Subject: [PATCH] Authentication working with LDAP --- application/config/autoload.php | 2 +- application/config/rest.php | 17 ++++++++++------- application/controllers/api/v1/APIAuth.php | 8 ++++---- .../libraries/{FHC_Auth.php => Fhcauth.php} | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) rename application/libraries/{FHC_Auth.php => Fhcauth.php} (98%) diff --git a/application/config/autoload.php b/application/config/autoload.php index 4be764662..2ddafebad 100755 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -60,7 +60,7 @@ $autoload['packages'] = array(); */ //$autoload['libraries'] = array(); -$autoload['libraries'] = array('session', 'FHC_Auth'); +$autoload['libraries'] = array('session', 'Fhcauth'); //$autoload['libraries'] = array(); $autoload['libraries'] = array('session'); diff --git a/application/config/rest.php b/application/config/rest.php index f1914a1b3..af3650d87 100644 --- a/application/config/rest.php +++ b/application/config/rest.php @@ -126,7 +126,7 @@ $config['rest_auth'] = 'basic'; | Note: If 'rest_auth' is set to 'session' then change 'auth_source' to the name of the session variable | */ -$config['auth_source'] = 'RestAPISession'; +$config['auth_source'] = 'library'; /* |-------------------------------------------------------------------------- @@ -144,7 +144,7 @@ $config['auth_source'] = 'RestAPISession'; | e.g: md5('admin:REST API:1234') = '1e957ebc35631ab22d5bd6526bd14ea2' | */ -$config['auth_library_class'] = 'FHCAuth'; +$config['auth_library_class'] = 'fhcauth'; $config['auth_library_function'] = 'auth'; /* @@ -163,7 +163,10 @@ $config['auth_library_function'] = 'auth'; | $config['auth_override_class_method']['accounts']['user'] = 'basic'; | $config['auth_override_class_method']['dashboard']['*'] = 'none|digest|basic'; | -| Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. An asterisk may also be used to specify an authentication method for an entire classes methods. Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end of the method name) +| Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. + * An asterisk may also be used to specify an authentication method for an entire classes methods. + * Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end + * of the method name) | Acceptable values are; 'none', 'digest' and 'basic'. | */ @@ -196,10 +199,10 @@ $config['auth_library_function'] = 'auth'; | REST Login Usernames |-------------------------------------------------------------------------- | -| Array of usernames and passwords for login, if ldap is configured this is ignored +| Array of usernames and passwords for login, if ldap (even library) is configured this is ignored | */ -$config['rest_valid_logins'] = ['admin' => '1234']; +$config['rest_valid_logins'] = ['admin' => '1234', 'test' => 'test']; /* |-------------------------------------------------------------------------- @@ -216,7 +219,7 @@ $config['rest_valid_logins'] = ['admin' => '1234']; | restrict certain methods to IPs in your whitelist | */ -$config['rest_ip_whitelist_enabled'] = FALSE; +$config['rest_ip_whitelist_enabled'] = TRUE; /* |-------------------------------------------------------------------------- @@ -301,7 +304,7 @@ $config['rest_keys_table'] = 'ci_apikey'; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | */ -$config['rest_enable_keys'] = FALSE; +$config['rest_enable_keys'] = TRUE; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/api/v1/APIAuth.php b/application/controllers/api/v1/APIAuth.php index 1d289be79..b8d24f9b8 100644 --- a/application/controllers/api/v1/APIAuth.php +++ b/application/controllers/api/v1/APIAuth.php @@ -23,7 +23,7 @@ if (! defined('BASEPATH')) /** * Handles user authentication and registration process */ -class AuthAPI extends APIv1_Controller +class APIAuth extends APIv1_Controller { /** * Userauth-Controller constructor. @@ -42,7 +42,7 @@ class AuthAPI extends APIv1_Controller // Load helper //$this->load->helper('fhcauth'); $this->load->library('session'); - $this->load->library('FHC_Auth'); + $this->load->library('Fhcauth'); } /** @@ -60,8 +60,8 @@ class AuthAPI extends APIv1_Controller $httpstatus = null; $username = urldecode($this->get('username')); $password = urldecode($this->get('password')); - - $account = $this->FHCAuth->auth($username, $password); + + $account = $this->fhcauth->auth($username, $password); // perform login checks if (!$account) diff --git a/application/libraries/FHC_Auth.php b/application/libraries/Fhcauth.php similarity index 98% rename from application/libraries/FHC_Auth.php rename to application/libraries/Fhcauth.php index 4e715efe3..3fda76f57 100644 --- a/application/libraries/FHC_Auth.php +++ b/application/libraries/Fhcauth.php @@ -25,7 +25,7 @@ require_once FCPATH.'include/authentication.class.php'; // ------------------------------------------------------------------------ -class FHC_Auth +class Fhcauth { /** * Auth Username, Password over FH-Complete