• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SAML - simplesamlphp

Hi All,
I've finally cracked this Smile
If you find yourself in a situation where you want to integrate saml based SSO with your CI app then read on..

The key to success was to NOT use the phpsession driver for SimpleSAMLphp.
Once i've switched to using a SQL database for it, the session restore functionality started working.

So, just ensure that the config/config.php is not using phpsession as storetype:
PHP Code:
'store.type'         => 'sql'

Then it as simple as the below to integrate authentication in codeigniter:
PHP Code:
public function auth()
       // Ensure we are not running in cli mode
       if (!is_cli())
           // SimpleSAMLphp is installed under /var/simplesaml

           // Authenticate against the 'default-sp' identity provider
           $auth = new \SimpleSAML\Auth\Simple('default-sp');

           if (!$auth->isAuthenticated())
               // The user is not authenticated.

               // We are authenticated, let's get the attributes
               $attributes $auth->getAttributes();

               // Restore codeigniter's session
               $session SimpleSAML_Session::getSessionFromRequest();

               // Add the attributes to the restored session
               $_SESSION['attributes'] = $attributes;

             // Do something based on attributes:
            // redirect, etc..


My plan is to get the above integrated with Ion Auth, where the above function will use hooks set up and log in the users locally, then i can use Ion Auth to manage the authorizations to different parts of the application Smile

Messages In This Thread
SAML - simplesamlphp - by qury - 11-02-2018, 05:31 PM
RE: SAML - simplesamlphp - by qury - 11-05-2018, 10:59 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.