Guest Posted November 13, 2015 Share Posted November 13, 2015 hi all. I have done a search in these forums but cant seem to find anything on this so i am making a new post. Apologies if this question has been answered else where. To slave IPS4 (forums) to our central authentication system i have done as instructed and created a pluggin that extents \ips\front and hooks the read member. Below is the code all sensitive information has been replaces with 'x' Quote public function read( $sessionId ) { /* Let normal class do its thing */ $result = call_user_func_array( 'parent::read', func_get_args() ); /* Fetch the session data again */ $key = "session_{$sessionId}"; $session = NULL; if ( isset( \IPS\Data\Cache::i()->$key ) ) { $session = \IPS\Data\Cache::i()->$key; } else { try { $session = \IPS\Db::i()->select( '*', 'core_sessions', array( 'id=?', $sessionId ) )->first(); } catch ( \UnderflowException $e ) { } } /* Only use sessions with matching IP address */ if( \IPS\Settings::i()->match_ipaddress and $session['ip_address'] != \IPS\Request::i()->ipAddress() ) { $session = NULL; } $this->member->language()->words['login_handler_ipscom'] = "Invisionpower.com"; $docRoot = realpath($_SERVER["DOCUMENT_ROOT"]); define('AUTH_ROOT',$docRoot.'/../auth2/'); include_once(AUTH_ROOT.'auth2Api.class.php'); $auth2Api = new \authApi(); $Key = 'xxxxxxxx'; $authSesID = (isset($_COOKIE['_aceAuth'])?$_COOKIE['_aceAuth']:0); $args=array('sessionID'=>$authSesID); $authUser = $auth2Api->request($Key,'user_is_logged_in',$args); if( $authUser['status']=='success') { if($authUser['data'] !==0) { $args=array('userID'=>$authUser['data']); $authReturn = $auth2Api->request($Key,'fetch_IPS4_member_id',$args); if($authReturn['status']=='success') { $member = \IPS\Member::load( $authReturn['data'] ); $this->member = $member; $this->save = TRUE; $this->data['already_checked'] = 0; } } } // this is here for testing purposes only $data = $this->member->member_id; $db = new \mysqli(xxxx','xxxx','xxxxx', 'xxxx'); $db->query("INSERT INTO `ace_auth2`.`ssoTest` (string) VALUES('$data')"); /* Finally, return our session result as normal */ return $result; } The issue is the this code is not being called each time the forums are loaded. Exmaple outcome is usually as follows. 1. Login to auth platform. 2. Open IPS forums, not logged in 3. Reload forums page, not logged in 4. reload forums page, now i am logged in. The reason i am sure that its not my code but rather than the hook not being called on each load is the testing code at the bottom of the hook. This a simple query which inserts the member_id into db table. Should member_id not exists or be blank an empty field is inserted into the db (tested). On the occasions that the forums page is reloaded and it fails to log in, no row is added at all in the table, bringing me to the conclusion that the plug-in hook is not being called on each refresh. I have also tried the checking cookies to login with the same effect, having to reload the forums repeatedly to get a log in. Any help here would be appreciated. Thx James Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.