User management hybrid auth setup

804 views Asked by At

I'm trying to setup hybrid auth on the Yii user management addon, the docs are here https://github.com/thyseus/yii-user-management/blob/master/user/docs/hybridauth.txt

according to this step

Take the modules/user/vendors/index.php, rename it to 'hybridauth.php' and place it 
    beside your application index.php bootstrap script. This will be your hybrid auth
    entry script. 

for this, there is NO index.php file in modules/user/vendors/index.php but there is one in modules/user/vendors/hybridauth/index.php which i renamed to hybridauth.php and put it in http://localhost/dev/ content of the hybridauth.php are

require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Auth.php" );

require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php" ); 

Hybrid_Endpoint::process();

now for this

Place the hybrid auth configuration file into your application
protected/config/hybridauth.php. 

i took my modules/user/vendors/hybridauth/config.php and put it in protected/config/ and renamed config.php to hybridauth.php. the content looks like this

return 
    array(
        "base_url" => Yii::app()->createAbsoluteUrl('/').'/hybridauth.php',
        "providers" => array ( 
            
...........
            "Google" => array ( 
                "enabled" => true,
                "keys"    => array (  
                            "id" => "ID", 
                            "secret" => "SECRET",
                        ), 
            ),

            "Facebook" => array ( 
                "enabled" => true,
                "keys"    => array ( 
                        "id" => "ID", 
                        "secret" => "SECRET",
                ), 
                "scope" => "email,user_birthday" // https://developers.facebook.com/docs/reference/login/
            ),
        ),

        // if you want to enable logging, set 'debug_mode' to true  then provide a writable file by the web server on "debug_file"
        "debug_mode" => false,

        "debug_file" => "",
    );

problem is when i click say on the facebook icon on my login page, it shows my main page. (index.php)

here is the link it directs too

http://localhost/dev/index.php/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835

when i remove the index.php from the url

http://localhost/dev/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835

i get this error

You cannot access this page directly.

any idea what i'm doing wrong? Thanks

3

There are 3 answers

0
DarkMukke On

This sound like a routing problem in your configuration:

you might want to add a route for hybridauth.php and make sure it is only accessable by GET

for example :

'components'=>array(
    ......
    'urlManager'=>array(
        'showScriptName' => false,
        'urlFormat'=>'path',
        'rules'=>array(
            'hybridauth'=>array('user/hybridauth/index', 'verb'=>'GET', 'urlSuffix'=>'.php'),
             ....
        ),
    ),
),
0
Firezilla12 On

if anyone having the same problem, here is how i solved it:

by changing the base_url to point to the actual php file:

"base_url" => Yii::app()->getBaseUrl(true).'/hybridauth.php', 
0
stavgian On

If you use YUM User Managment try to import

 Yii::import('application.modules.profile.models.*');

on YumUserAuthController because profile cannot be found.