Single sign-on using Joomla and Flash

I have a Joomla website and a Flash application (in Flex, if that matters). The Flash application uses BlazeDS as source code. All things are hosted on the same server in the same domain.

Is there a way to implement SSO for the above environment?

Update:

I want: If the user is logged in to Joomla, they will be automatically registered in the Flash application. The same thing and vice versa.

+3
source share
2 answers

You will need to create a component to handle the input.

The actual login code is very simple. Here is an example from the component that we developed for Joomla 1.5.

/**
     * Log into Joomla
     * @return Bool Login Status
     * @param $username String
     * @param $password String
     */
    function login($username, $password, $remember = false) {
        if ($username && $password) {
            $mainframe =& JFactory::getApplication();
            return $mainframe->login(
                array('username'=>$username, 'password'=>$password),
                array('remember'=> $remember, 'silent'=>true)
            );
        }
        return false;
    }

, PHP : http://www.fijiwebdesign.com/products/joomla-php-pages.html

, , URL- Joomla. :

example.com/index.php?option={com_component}&template=component&no_html=1

{com_component} - .

Joomla PHP Component :

example.com/index.php?option=com_php&Itemid={itemid}&template=component&no_html=1

Itemid - Itemid , PHP-. PHP PHP.

& template = component & no_html = 1 , HTML, no_html , - HTML.

, , , , JSON XML, Flex URLLoader . TRUE, FALSE.

:

, , . , Joomla, Flash-. .

, Joomla, , .

, Joomla:

$User =& JFactory::getUser();
if (!$User->guest) {
  // user is logged in
} else {
  // user is not logged in
}

:

$Session =& JFactory::getSession();
$sessid = $Session->getId();

:

session_name();

Joomla Flash:

$User =& JFactory::getUser();
$Session =& JFactory::getSession();
// for example use JSON which Flex undertands
echo json_encode((object) array('user'=>$User, 'session'=>$Session, 'name'=>session_name ());

, . Flash- Flash Joomla, - ExternalInterface (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html).

Flex . , cookie . cookie , , .

ExternalInterface cookie JavaScript .

cookie , Flex .

BlazeDS Joomla, BlazeDS, .

, Joomla, Flash, flashvars, ExternalInterface.

+2

, j-amfphp. โ€‹โ€‹, Flex , joomla.

, joomla ( ), : /joomlaapp/amfphp/includes/application.php

:

parent::__construct

jimport('joomla.utilities.utility');


if( $_COOKIE["j-amfphp_admin"] == true )
{
 //set the view name
 $this->_name  = "administrator";
}
else
{
 //set the view name
 $this->_name  = "site";
}
$this->_clientId = $config['clientId'];

//Enable sessions by default
if(!isset($config['session'])) {
 $config['session'] = true;
}

//Set the session default name
if(!isset($config['session_name'])) {
  $config['session_name'] = $this->_name;
}

  //Set the default configuration file
if(!isset($config['config_file'])) {
 $config['config_file'] = 'configuration.php';
}

//create the configuration object
$this->_createConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']);

//create the session if a session name is passed
if($config['session'] !== false) {
 $this->_createSession(JUtility::getHash($config['session_name']));
}

$this->set( 'requestTime', gmdate('Y-m-d H:i') );

, , , cookie, , , Flex ... , cookie .

, Flex , , $this โ†’ _ name. flex, .

+1

Source: https://habr.com/ru/post/1720205/


All Articles