Redirect after SSOHandler

Author Message

Jean-Luc Chassaing

Wednesday 22 October 2008 5:38:43 am

My web site is behind an SSO authentification.

My SSOHandler logs the correct user. My problem comes after.

The SSoHandler is called in the ezuser::instance() function.

Once the ssohandler has returned the correcte ezuser instance, some variables are set and then eZHTTPTool::redirect is called.

The url called by the redirect is defined in the eZHTTPTool::createRedirectUrl() function with the $_SERVER['host'] variable.

I need to use an other Server parameter but i don't want to hack the datatype/ezuser.php file.

How can I manage that ?

Arnaud Lafon

Tuesday 18 November 2008 6:58:57 am

Hi Jean-Luc,

assuming you're running ezp 4.0.1, you should have this in ezuser.php on line 1122 :

                    else // check in extensions
                    {
                        //include_once( 'lib/ezutils/classes/ezextension.php' );
                        $ini = eZINI::instance();
                        $extensionDirectories = $ini->variable( 'UserSettings', 'ExtensionDirectory' );
                        $directoryList = eZExtension::expandedPathList( $extensionDirectories, 'sso_handler' );
                        foreach( $directoryList as $directory )
                        {
                            $handlerFile = $directory . '/ez' . strtolower( $ssoHandler ) . 'ssohandler.php';
                            if ( file_exists( $handlerFile ) )
                            {
                                include_once( $handlerFile );
                                $className = 'eZ' . $ssoHandler . 'SSOHandler';
                                $impl = new $className();
                                $ssoUser = $impl->handleSSOLogin();
                            }
                        }
                    }
                }
                // If a user was found via SSO, then use it
                if ( $ssoUser !== false )
                {
                    $currentUser = $ssoUser;

                    $userInfo = array();
                    $userInfo[$id] = array( 'contentobject_id' => $currentUser->attribute( 'contentobject_id' ),
                                            'login' => $currentUser->attribute( 'login' ),
                                            'email' => $currentUser->attribute( 'email' ),
                                            'password_hash' => $currentUser->attribute( 'password_hash' ),
                                            'password_hash_type' => $currentUser->attribute( 'password_hash_type' )
                                            );
                    $http->setSessionVariable( 'eZUserInfoCache', $userInfo );
                    $http->setSessionVariable( 'eZUserInfoCache_Timestamp', time() );
                    $http->setSessionVariable( 'eZUserLoggedInID', $id );
                    eZSessionSetUserID( $currentUser->attribute( 'contentobject_id' ) );

                    eZUser::updateLastVisit( $currentUser->attribute( 'contentobject_id' ) );
                    eZUser::setCurrentlyLoggedInUser( $currentUser, $currentUser->attribute( 'contentobject_id' ) );
                    eZHTTPTool::redirect( eZSys::wwwDir() . eZSys::indexFile( false ) . eZSys::requestURI(), array(), 201 );

                }

The problem is that on the last line, eZHTTPTool::redirect is called with hard-coded parameters so you cannot call a different host.

What you can do is doing the redirect in your ssohandler which is called on line 1136.
Copy and paste at the end of your own loginUser() method the code in the if ( $ssoUser !== false ) { ... } and replace
eZHTTPTool::redirect( eZSys::wwwDir() . eZSys::indexFile( false ) . eZSys::requestURI(), array(), 201 )
by
<b>$parameters = array( "host" => "a_different_host", "protocol" => "http" );</b>
eZHTTPTool::redirect( eZSys::wwwDir() . eZSys::indexFile( false ) . eZSys::requestURI(), <b>$parameters</b>, 201 )
return $user;

Hope this help.

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Jianjun Hu

Thursday 18 June 2009 12:25:49 am

Maybe I meet the similar problem. My eZ Publish is 4.1.3. I'm try to work out.

OnlyBlue

☆..·°∴°.☆°°.☆°.
°∴ °☆ .·enjoy star° .·★°∴°
∴°.°★ .·°
  ミ☆°∴°.★☆° ∴·°
°.☆° .·∴° 

Is it a pleasure after all to practice in due time what one has learnt?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:45:29
Script start
Timing: Jan 18 2025 11:45:30
Module start 'layout'
Timing: Jan 18 2025 11:45:30
Module start 'content'
Timing: Jan 18 2025 11:45:30
Module end 'content'
Timing: Jan 18 2025 11:45:30
Script end

Main resources:

Total runtime0.6962 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.9141152.6250
Module start 'layout' 0.00680.0037 740.539139.4453
Module start 'content' 0.01050.6845 779.9844595.4531
Module end 'content' 0.69500.0012 1,375.437516.1641
Script end 0.6962  1,391.6016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.5490160.0002
Check MTime0.00170.2471160.0001
Mysql Total
Database connection0.00080.109110.0008
Mysqli_queries0.634291.0861590.0107
Looping result0.00080.1080570.0000
Template Total0.663295.320.3316
Template load0.00240.351320.0012
Template processing0.660794.900420.3304
Template load and register function0.00020.030810.0002
states
state_id_array0.00170.249310.0017
state_identifier_array0.00120.168620.0006
Override
Cache load0.00220.3212290.0001
Sytem overhead
Fetch class attribute can translate value0.00080.109330.0003
Fetch class attribute name0.00220.310860.0004
XML
Image XML parsing0.00460.664730.0015
class_abstraction
Instantiating content class attribute0.00000.001860.0000
General
dbfile0.00380.5529290.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs