__PHP_Incomplete_Class when trying to access an object stored in session

by user615274   Last Updated September 09, 2019 21:10 PM

I work on implementing single sign on with joomla and simplesamlphp.

I try to use the simpleamlphp api in the context of a joomla plugin in the onAfterInitialise event.

To that end, the plugin in the onAfterInitialise event detects if there are in the parameters sent by the HTTP request one with name simplesamlphp and with valuesso, if it is true I start the object \SimpleSAML\Auth\Simple and start the authentication process by calling the requireAuth() method. This shows the simpleamlphp authentication form and by providing valid credentials redirects me to the site that initiated the authentication process, here I try to access the attributes of the authenticated user.

My problem is that I cannot access the attributes of the authenticated user in simplesamlphp because I cannot access the original instance of the \SimpleSAML\ Auth\Simple object

I am now trying to save the object in a session variable but I am getting the class error __PHP_Incomplete_Class

This is the code I'm trying

<?php

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

require_once('/var/simplesamlphp/lib/_autoload.php');

class plgSystemMysamlredirect extends JPlugin
{
    public function onAfterInitialise()
    {
        $application = JFactory::getApplication();
        $session = JFactory::getSession();

        $jinput = $application->input;

        $get = (object) $jinput->get->getArray();

        if (isset($get->simplesamlphp) && $get->simplesamlphp === 'sso') {
            $auth = new SimpleSAML_Auth_Simple('default-sp');

            $session->set('auth', $auth);

            $auth->requireAuth();
        }

        $auth = $session->get('auth');

        if (!is_null($auth)) {
            if ($auth->isAuthenticated()) {
                $attributes = $auth->getAttributes();

                print_r($attributes);
            }
        }
    }
}

I welcome your comments and suggestions



Related Questions


Updated January 06, 2019 18:10 PM

Updated May 28, 2017 04:10 AM

Updated July 14, 2015 17:04 PM

Updated July 11, 2018 11:10 AM

Updated July 24, 2019 20:10 PM