Hybridauth for yii
Demo and info on the official hybridauth page above
[color="#FF0000"]EDIT* Made major updates today, new sql and new instructions. Please read, I’m sorry for inconvience but I realised I had to change the structur to provide more functions.
New are also easy methods to access facebook/twitter api,save/load user sessions
and update user status. [/color]
In short, hybridauth is a library that makes working with auth api’s from diffrent providers alot easier. With the addon it currently has support for 29 providers,facebook,twitter,google,tumblr,myspace etc aswell as any openid server.
[size="5"]Instructions:[/size]
Put hybridauth folder in your root, and if you want to use the same (huge) icons I used put the login_icons dir in your root/images.
Import /yiiauth/social.sql to your database, change prefix if needed.
Put yiiauth folder in protected/modules.
You have to extend application.components.controller to Yiiauth
<?php class Controller extends Yiiauth{...?>
You can then extend Yiiauth/components/yiiauth from CController,RController or whatever you using:)
In your protected/config/main.php’s import array, add ‘application.modules.yiiauth.components.*’,
and add into ‘modules’ array add:
'yiiauth'=>array(
'userClass'=>'User', //the name of your Userclass
'config'=>array(
"base_url" => "http://domain/hybridauth/",
"providers" => array (
// openid providers
"OpenID" => array (
"enabled" => true
),
"Yahoo" => array (
"enabled" => true
),
"AOL" => array (
"enabled" => true
),
"Google" => array (
"enabled" => true,
"keys" => array ("id" => "", "secret" => "" ),
"scope" => ""
),
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "", "secret" => "" ),
// A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: http://developers.facebook.com/docs/reference/api/permissions.
"scope" => "",
// The display context to show the authentication page. Options are: page, popup, iframe, touch and wap. Read the Facebook docs for more details: http://developers.facebook.com/docs/reference/dialogs#display. Default: page
"display" => "page"
),
"Twitter" => array (
"enabled" => true,
"keys" => array ( "key" => "rPmGEE1Wvsf56BSyQaWXw", "secret" => "V4SK09O0cPOgkabsxR5AruBSNrc0b1tzoBeWkL7ew0" )
),
// windows live
"Live" => array (
"enabled" => true,
"keys" => array ( "id" => "", "secret" => "" )
),
"MySpace" => array (
"enabled" => false,
"keys" => array ( "key" => "", "secret" => "" )
),
"LinkedIn" => array (
"enabled" => true,
"keys" => array ( "key" => "", "secret" => "" )
),
"Foursquare" => array (
"enabled" => false,
"keys" => array ( "id" => "", "secret" => "" )
),
),
// 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" => "",
),
)
You have to registrate your app on facebook/twitter etc to recieve a key and a secret.
Set these keys in the config array (how to configure more options can be found on the hybridauth page I linked at thop.
Also dont forget to set your path to hybridauth in that config.
For openID no special key/secret is needed.
To try out on your site there is a loginwidget that can be used simply like this:
<?php $this->widget('LoginWidget');?>
You can also just browse to domain.com/yiiauth/ to test.
What you will se when you have authenticated is a sample/help view (yiiauth/views/default/profile.php).
Here you can see how to update a users status, use twitter or facebook api calls,store a session in database and retrieve it later
Make sure to look in the source code.
I haven’t added a full user system to this module because I believe most wants to solve this their own way.
But it includes code to create a yii-user,connect them with the provider user etc.
Download (newest)
NOW ON GIT HUB : https://github.com/Sampa/yiiauth
feel free to commit improvements