mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 04:40:44 +02:00
HybridAuth updated to 2.1.0
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
class Hybrid_Auth
|
class Hybrid_Auth
|
||||||
{
|
{
|
||||||
public static $version = "2.0.11-dev";
|
public static $version = "2.1.0";
|
||||||
|
|
||||||
public static $config = array();
|
public static $config = array();
|
||||||
|
|
||||||
@@ -28,37 +28,14 @@ class Hybrid_Auth
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to start a new session of none then initialize Hybrid_Auth
|
* Try to start a new session of none then initialize Hybrid_Auth
|
||||||
*
|
*
|
||||||
* Hybrid_Auth constructor will require either a valid config array or
|
* Hybrid_Auth constructor will require either a valid config array or
|
||||||
* a path for a configuration file as parameter. To know more please
|
* a path for a configuration file as parameter. To know more please
|
||||||
* refer to the Configuration section:
|
* refer to the Configuration section:
|
||||||
* http://hybridauth.sourceforge.net/userguide/Configuration.html
|
* http://hybridauth.sourceforge.net/userguide/Configuration.html
|
||||||
*/
|
*/
|
||||||
function __construct( $config )
|
function __construct( $config )
|
||||||
{
|
{
|
||||||
if ( ! session_id() ){
|
|
||||||
if( ! session_start() ){
|
|
||||||
throw new Exception( "Hybridauth requires the use of 'session_start()' at the start of your script, which appears to be disabled.", 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#{{{ well, should we check this each time? ..
|
|
||||||
// PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
|
|
||||||
if ( ! function_exists('curl_init') ) {
|
|
||||||
throw new Exception('Hybridauth Library needs the CURL PHP extension.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// PHP JSON extension [http://php.net/manual/en/book.json.php]
|
|
||||||
if ( ! function_exists('json_decode') ) {
|
|
||||||
throw new Exception('Hybridauth Library needs the JSON PHP extension.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// OAuth PECL extension is not compatible with this library
|
|
||||||
if( extension_loaded('oauth') ) {
|
|
||||||
throw new Exception('Hybridauth Library not compatible with installed PECL OAuth extension. Please disable it.');
|
|
||||||
}
|
|
||||||
#}}}
|
|
||||||
|
|
||||||
Hybrid_Auth::initialize( $config );
|
Hybrid_Auth::initialize( $config );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,17 +46,13 @@ class Hybrid_Auth
|
|||||||
*/
|
*/
|
||||||
public static function initialize( $config )
|
public static function initialize( $config )
|
||||||
{
|
{
|
||||||
if ( ! session_id() ){
|
|
||||||
throw new Exception( "Hybriauth require the use of 'session_start()' at the start of your script.", 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ! is_array( $config ) && ! file_exists( $config ) ){
|
if( ! is_array( $config ) && ! file_exists( $config ) ){
|
||||||
throw new Exception( "Hybriauth config does not exist on the given path.", 1 );
|
throw new Exception( "Hybriauth config does not exist on the given path.", 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! is_array( $config ) ){
|
if( ! is_array( $config ) ){
|
||||||
$config = include $config;
|
$config = include $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build some need'd paths
|
// build some need'd paths
|
||||||
$config["path_base"] = realpath( dirname( __FILE__ ) ) . "/";
|
$config["path_base"] = realpath( dirname( __FILE__ ) ) . "/";
|
||||||
@@ -94,19 +67,19 @@ class Hybrid_Auth
|
|||||||
}
|
}
|
||||||
|
|
||||||
# load hybridauth required files, a autoload is on the way...
|
# load hybridauth required files, a autoload is on the way...
|
||||||
require_once $config["path_base"] . "Error.php";
|
require_once $config["path_base"] . "Error.php";
|
||||||
require_once $config["path_base"] . "Logger.php";
|
require_once $config["path_base"] . "Logger.php";
|
||||||
|
|
||||||
require_once $config["path_base"] . "Storage.php";
|
require_once $config["path_base"] . "Storage.php";
|
||||||
|
|
||||||
require_once $config["path_base"] . "Provider_Adapter.php";
|
require_once $config["path_base"] . "Provider_Adapter.php";
|
||||||
|
|
||||||
require_once $config["path_base"] . "Provider_Model.php";
|
require_once $config["path_base"] . "Provider_Model.php";
|
||||||
require_once $config["path_base"] . "Provider_Model_OpenID.php";
|
require_once $config["path_base"] . "Provider_Model_OpenID.php";
|
||||||
require_once $config["path_base"] . "Provider_Model_OAuth1.php";
|
require_once $config["path_base"] . "Provider_Model_OAuth1.php";
|
||||||
require_once $config["path_base"] . "Provider_Model_OAuth2.php";
|
require_once $config["path_base"] . "Provider_Model_OAuth2.php";
|
||||||
|
|
||||||
require_once $config["path_base"] . "User.php";
|
require_once $config["path_base"] . "User.php";
|
||||||
require_once $config["path_base"] . "User_Profile.php";
|
require_once $config["path_base"] . "User_Profile.php";
|
||||||
require_once $config["path_base"] . "User_Contact.php";
|
require_once $config["path_base"] . "User_Contact.php";
|
||||||
require_once $config["path_base"] . "User_Activity.php";
|
require_once $config["path_base"] . "User_Activity.php";
|
||||||
@@ -114,25 +87,55 @@ class Hybrid_Auth
|
|||||||
// hash given config
|
// hash given config
|
||||||
Hybrid_Auth::$config = $config;
|
Hybrid_Auth::$config = $config;
|
||||||
|
|
||||||
// start session storage mng
|
|
||||||
Hybrid_Auth::$store = new Hybrid_Storage();
|
|
||||||
|
|
||||||
// instace of errors mng
|
|
||||||
Hybrid_Auth::$error = new Hybrid_Error();
|
|
||||||
|
|
||||||
// instace of log mng
|
// instace of log mng
|
||||||
Hybrid_Auth::$logger = new Hybrid_Logger();
|
Hybrid_Auth::$logger = new Hybrid_Logger();
|
||||||
|
|
||||||
// store php session and version..
|
// instace of errors mng
|
||||||
$_SESSION["HA::PHP_SESSION_ID"] = session_id();
|
Hybrid_Auth::$error = new Hybrid_Error();
|
||||||
$_SESSION["HA::VERSION"] = Hybrid_Auth::$version;
|
|
||||||
|
// start session storage mng
|
||||||
|
Hybrid_Auth::$store = new Hybrid_Storage();
|
||||||
|
|
||||||
// almost done, check for errors then move on
|
|
||||||
Hybrid_Logger::info( "Enter Hybrid_Auth::initialize()");
|
Hybrid_Logger::info( "Enter Hybrid_Auth::initialize()");
|
||||||
Hybrid_Logger::info( "Hybrid_Auth::initialize(). Hybrid_Auth used version: " . Hybrid_Auth::$version );
|
Hybrid_Logger::info( "Hybrid_Auth::initialize(). PHP version: " . PHP_VERSION );
|
||||||
|
Hybrid_Logger::info( "Hybrid_Auth::initialize(). Hybrid_Auth version: " . Hybrid_Auth::$version );
|
||||||
Hybrid_Logger::info( "Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl() );
|
Hybrid_Logger::info( "Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl() );
|
||||||
|
|
||||||
|
// PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
|
||||||
|
if ( ! function_exists('curl_init') ) {
|
||||||
|
Hybrid_Logger::error('Hybridauth Library needs the CURL PHP extension.');
|
||||||
|
throw new Exception('Hybridauth Library needs the CURL PHP extension.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// PHP JSON extension [http://php.net/manual/en/book.json.php]
|
||||||
|
if ( ! function_exists('json_decode') ) {
|
||||||
|
Hybrid_Logger::error('Hybridauth Library needs the JSON PHP extension.');
|
||||||
|
throw new Exception('Hybridauth Library needs the JSON PHP extension.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// OAuth PECL extension is not compatible with this library
|
||||||
|
if( extension_loaded('oauth') ) {
|
||||||
|
Hybrid_Logger::error('Hybridauth Library not compatible with installed PECL OAuth extension. Please disable it.');
|
||||||
|
throw new Exception('Hybridauth Library not compatible with installed PECL OAuth extension. Please disable it.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// session.name
|
||||||
|
if( session_name() != "PHPSESSID" ){
|
||||||
|
Hybrid_Logger::info('PHP session.name diff from default PHPSESSID. http://php.net/manual/en/session.configuration.php#ini.session.name.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// safe_mode is on
|
||||||
|
if( ini_get('safe_mode') ){
|
||||||
|
Hybrid_Logger::info('PHP safe_mode is on. http://php.net/safe-mode.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// open basedir is on
|
||||||
|
if( ini_get('open_basedir') ){
|
||||||
|
Hybrid_Logger::info('PHP open_basedir is on. http://php.net/open-basedir.');
|
||||||
|
}
|
||||||
|
|
||||||
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump used config: ", serialize( $config ) );
|
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump used config: ", serialize( $config ) );
|
||||||
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump current session: ", serialize( $_SESSION ) );
|
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump current session: ", Hybrid_Auth::storage()->getSessionData() );
|
||||||
Hybrid_Logger::info( "Hybrid_Auth initialize: check if any error is stored on the endpoint..." );
|
Hybrid_Logger::info( "Hybrid_Auth initialize: check if any error is stored on the endpoint..." );
|
||||||
|
|
||||||
if( Hybrid_Error::hasError() ){
|
if( Hybrid_Error::hasError() ){
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,9 +10,6 @@
|
|||||||
*
|
*
|
||||||
* Hybrid_Endpoint class provides a simple way to handle the OpenID and OAuth endpoint.
|
* Hybrid_Endpoint class provides a simple way to handle the OpenID and OAuth endpoint.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Hybrid_Endpoint {
|
class Hybrid_Endpoint {
|
||||||
public static $request = NULL;
|
public static $request = NULL;
|
||||||
public static $initDone = FALSE;
|
public static $initDone = FALSE;
|
||||||
@@ -40,11 +37,6 @@ class Hybrid_Endpoint {
|
|||||||
Hybrid_Endpoint::$request = $_REQUEST;
|
Hybrid_Endpoint::$request = $_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If windows_live_channel requested, we return our windows_live WRAP_CHANNEL_URL
|
|
||||||
if ( isset( Hybrid_Endpoint::$request["get"] ) && Hybrid_Endpoint::$request["get"] == "windows_live_channel" ) {
|
|
||||||
Hybrid_Endpoint::processWindowsLiveChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If openid_policy requested, we return our policy document
|
// If openid_policy requested, we return our policy document
|
||||||
if ( isset( Hybrid_Endpoint::$request["get"] ) && Hybrid_Endpoint::$request["get"] == "openid_policy" ) {
|
if ( isset( Hybrid_Endpoint::$request["get"] ) && Hybrid_Endpoint::$request["get"] == "openid_policy" ) {
|
||||||
Hybrid_Endpoint::processOpenidPolicy();
|
Hybrid_Endpoint::processOpenidPolicy();
|
||||||
@@ -69,16 +61,6 @@ class Hybrid_Endpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Process Windows Live channel request
|
|
||||||
*/
|
|
||||||
public static function processWindowsLiveChannel()
|
|
||||||
{
|
|
||||||
$output = file_get_contents( dirname(__FILE__) . "/resources/windows_live_channel.html" );
|
|
||||||
print $output;
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process OpenID policy request
|
* Process OpenID policy request
|
||||||
*/
|
*/
|
||||||
@@ -138,7 +120,6 @@ class Hybrid_Endpoint {
|
|||||||
Hybrid_Logger::error( "Endpoint: hauth_endpoint parameter is not defined on hauth_start, halt login process!" );
|
Hybrid_Logger::error( "Endpoint: hauth_endpoint parameter is not defined on hauth_start, halt login process!" );
|
||||||
|
|
||||||
header( "HTTP/1.0 404 Not Found" );
|
header( "HTTP/1.0 404 Not Found" );
|
||||||
|
|
||||||
die( "You cannot access this page directly." );
|
die( "You cannot access this page directly." );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,33 +189,27 @@ class Hybrid_Endpoint {
|
|||||||
|
|
||||||
public static function authInit()
|
public static function authInit()
|
||||||
{
|
{
|
||||||
// print_a($_SESSION);
|
|
||||||
|
|
||||||
|
|
||||||
if ( ! Hybrid_Endpoint::$initDone) {
|
if ( ! Hybrid_Endpoint::$initDone) {
|
||||||
Hybrid_Endpoint::$initDone = TRUE;
|
Hybrid_Endpoint::$initDone = TRUE;
|
||||||
|
|
||||||
// Start a new session
|
|
||||||
if ( ! session_id() ){
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
# Init Hybrid_Auth
|
# Init Hybrid_Auth
|
||||||
try {
|
try {
|
||||||
|
require_once realpath( dirname( __FILE__ ) ) . "/Storage.php";
|
||||||
|
|
||||||
|
$storage = new Hybrid_Storage();
|
||||||
|
|
||||||
// Check if Hybrid_Auth session already exist
|
// Check if Hybrid_Auth session already exist
|
||||||
if ( ! isset( $_SESSION["HA::CONFIG"] ) ) {
|
if ( ! $storage->config( "CONFIG" ) ) {
|
||||||
header( "HTTP/1.0 404 Not Found" );
|
header( "HTTP/1.0 404 Not Found" );
|
||||||
die( "You cannot access this page directly." );
|
die( "You cannot access this page directly." );
|
||||||
}
|
}
|
||||||
|
|
||||||
Hybrid_Auth::initialize( unserialize( $_SESSION["HA::CONFIG"] ) );
|
Hybrid_Auth::initialize( $storage->config( "CONFIG" ) );
|
||||||
}
|
}
|
||||||
catch ( Exception $e ){
|
catch ( Exception $e ){
|
||||||
Hybrid_Logger::error( "Endpoint: Error while trying to init Hybrid_Auth" );
|
Hybrid_Logger::error( "Endpoint: Error while trying to init Hybrid_Auth" );
|
||||||
|
|
||||||
header( "HTTP/1.0 404 Not Found" );
|
header( "HTTP/1.0 404 Not Found" );
|
||||||
// print_a($_SESSION);
|
|
||||||
// echo "e=".$e;
|
|
||||||
die( "Oophs. Error!" );
|
die( "Oophs. Error!" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,11 +134,11 @@ class Hybrid_Provider_Adapter
|
|||||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_endpoint" , $this->params["login_done"] );
|
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_endpoint" , $this->params["login_done"] );
|
||||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.id_provider_params" , $this->params );
|
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.id_provider_params" , $this->params );
|
||||||
|
|
||||||
// store config to be used by the end point
|
// store config to be used by the end point
|
||||||
$_SESSION["HA::CONFIG"] = serialize( Hybrid_Auth::$config );
|
Hybrid_Auth::storage()->config( "CONFIG", Hybrid_Auth::$config );
|
||||||
|
|
||||||
// move on
|
// move on
|
||||||
Hybrid_Logger::debug( "Hybrid_Provider_Adapter::login( {$this->id} ), redirect the user to login_start URL.", $this->params );
|
Hybrid_Logger::debug( "Hybrid_Provider_Adapter::login( {$this->id} ), redirect the user to login_start URL." );
|
||||||
|
|
||||||
Hybrid_Auth::redirect( $this->params["login_start"] );
|
Hybrid_Auth::redirect( $this->params["login_start"] );
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,6 +82,11 @@ class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
|
|||||||
else{
|
else{
|
||||||
$this->api = new OAuth1Client( $this->config["keys"]["key"], $this->config["keys"]["secret"] );
|
$this->api = new OAuth1Client( $this->config["keys"]["key"], $this->config["keys"]["secret"] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set curl proxy if exist
|
||||||
|
if( isset( Hybrid_Auth::$config["proxy"] ) ){
|
||||||
|
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +75,11 @@ class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model
|
|||||||
$this->api->access_token_expires_in = $this->token( "expires_in" );
|
$this->api->access_token_expires_in = $this->token( "expires_in" );
|
||||||
$this->api->access_token_expires_at = $this->token( "expires_at" );
|
$this->api->access_token_expires_at = $this->token( "expires_at" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set curl proxy if exist
|
||||||
|
if( isset( Hybrid_Auth::$config["proxy"] ) ){
|
||||||
|
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +34,7 @@ class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
|
|||||||
// include LightOpenID lib
|
// include LightOpenID lib
|
||||||
require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
|
require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
|
||||||
|
|
||||||
$this->api = new LightOpenID( parse_url( Hybrid_Auth::$config["base_url"], PHP_URL_HOST) );
|
$this->api = new LightOpenID( parse_url( Hybrid_Auth::$config["base_url"], PHP_URL_HOST), Hybrid_Auth::$config["proxy"] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,9 +15,7 @@
|
|||||||
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
||||||
{
|
{
|
||||||
// default permissions, and alot of them. You can change them from the configuration by setting the scope to what you want/need
|
// default permissions, and alot of them. You can change them from the configuration by setting the scope to what you want/need
|
||||||
public $scope = "email, user_about_me, user_birthday, user_hometown, user_website, offline_access, read_stream, publish_stream, read_friendlists";
|
public $scope = "email, user_about_me, user_birthday, user_hometown, user_website, read_stream, offline_access, publish_stream, read_friendlists";
|
||||||
|
|
||||||
public $display = "page";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IDp wrappers initializer
|
* IDp wrappers initializer
|
||||||
@@ -28,16 +26,6 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
|||||||
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
|
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// override requested scope
|
|
||||||
if( isset( $this->config["scope"] ) && ! empty( $this->config["scope"] ) ){
|
|
||||||
$this->scope = $this->config["scope"];
|
|
||||||
}
|
|
||||||
|
|
||||||
// override requested display
|
|
||||||
if( isset( $this->config["display"] ) && ! empty( $this->config["display"] ) ){
|
|
||||||
$this->display = $this->config["display"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! class_exists('FacebookApiException') ) {
|
if ( ! class_exists('FacebookApiException') ) {
|
||||||
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/base_facebook.php";
|
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/base_facebook.php";
|
||||||
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/facebook.php";
|
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/facebook.php";
|
||||||
@@ -45,6 +33,17 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
|||||||
|
|
||||||
$this->api = new Facebook( ARRAY( 'appId' => $this->config["keys"]["id"], 'secret' => $this->config["keys"]["secret"] ) );
|
$this->api = new Facebook( ARRAY( 'appId' => $this->config["keys"]["id"], 'secret' => $this->config["keys"]["secret"] ) );
|
||||||
|
|
||||||
|
if ( $this->token("access_token") ) {
|
||||||
|
$access_token = $this->api->extendedAccessToken( $this->token("access_token") );
|
||||||
|
|
||||||
|
if( $access_token ){
|
||||||
|
$this->token("access_token", $access_token );
|
||||||
|
$this->api->setAccessToken( $access_token );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->api->setAccessToken( $this->token("access_token") );
|
||||||
|
}
|
||||||
|
|
||||||
$this->api->getUser();
|
$this->api->getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +54,17 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
|||||||
*/
|
*/
|
||||||
function loginBegin()
|
function loginBegin()
|
||||||
{
|
{
|
||||||
|
$parameters = array("scope" => $this->scope, "redirect_uri" => $this->endpoint, "display" => "page");
|
||||||
|
$optionals = array("scope", "redirect_uri", "display");
|
||||||
|
|
||||||
|
foreach ($optionals as $parameter){
|
||||||
|
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
|
||||||
|
$parameters[$parameter] = $this->config[$parameter];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get the login url
|
// get the login url
|
||||||
$url = $this->api->getLoginUrl( array( 'scope' => $this->scope, 'display' => $this->display, 'redirect_uri' => $this->endpoint ) );
|
$url = $this->api->getLoginUrl( $parameters );
|
||||||
|
|
||||||
// redirect to facebook
|
// redirect to facebook
|
||||||
Hybrid_Auth::redirect( $url );
|
Hybrid_Auth::redirect( $url );
|
||||||
@@ -80,10 +88,8 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
|||||||
// set user as logged in
|
// set user as logged in
|
||||||
$this->setUserConnected();
|
$this->setUserConnected();
|
||||||
|
|
||||||
// try to detect the access token for facebook
|
// store facebook access token
|
||||||
if( isset( $_SESSION["fb_" . $this->api->getAppId() . "_access_token" ] ) ){
|
$this->token( "access_token", $this->api->getAccessToken() );
|
||||||
$this->token( "access_token", $_SESSION["fb_" . $this->api->getAppId() . "_access_token" ] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +45,7 @@ class Hybrid_Providers_Foursquare extends Hybrid_Provider_Model_OAuth2
|
|||||||
$this->user->profile->lastName = $data->lastName;
|
$this->user->profile->lastName = $data->lastName;
|
||||||
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
||||||
$this->user->profile->photoURL = $data->photo;
|
$this->user->profile->photoURL = $data->photo;
|
||||||
$this->user->profile->profileURL = $data->canonicalUrl;
|
$this->user->profile->profileURL = "https://www.foursquare.com/user/" . $data->id;
|
||||||
$this->user->profile->gender = $data->gender;
|
$this->user->profile->gender = $data->gender;
|
||||||
$this->user->profile->city = $data->homeCity;
|
$this->user->profile->city = $data->homeCity;
|
||||||
$this->user->profile->email = $data->contact->email;
|
$this->user->profile->email = $data->contact->email;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +33,16 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2
|
|||||||
*/
|
*/
|
||||||
function loginBegin()
|
function loginBegin()
|
||||||
{
|
{
|
||||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( array( "scope" => $this->scope, "access_type" => "offline" ) ) );
|
$parameters = array("scope" => $this->scope, "access_type" => "offline");
|
||||||
|
$optionals = array("scope", "access_type", "redirect_uri", "approval_prompt");
|
||||||
|
|
||||||
|
foreach ($optionals as $parameter){
|
||||||
|
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
|
||||||
|
$parameters[$parameter] = $this->config[$parameter];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Hybrid_Auth::redirect( $this->api->authorizeUrl( $parameters ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +91,12 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2
|
|||||||
// refresh tokens if needed
|
// refresh tokens if needed
|
||||||
$this->refreshToken();
|
$this->refreshToken();
|
||||||
|
|
||||||
$response = $this->api->api( "https://www.google.com/m8/feeds/contacts/default/full?alt=json" );
|
if( ! isset( $this->config['contacts_param'] ) ){
|
||||||
|
$this->config['contacts_param'] = array( "max-results" => 500 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->api->api( "https://www.google.com/m8/feeds/contacts/default/full?"
|
||||||
|
. http_build_query( array_merge( array('alt' => 'json'), $this->config['contacts_param'] ) ) );
|
||||||
|
|
||||||
if( ! $response ){
|
if( ! $response ){
|
||||||
return ARRAY();
|
return ARRAY();
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +90,7 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model
|
|||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
// http://developer.linkedin.com/docs/DOC-1061
|
// http://developer.linkedin.com/docs/DOC-1061
|
||||||
$response = $this->api->profile('~:(id,first-name,last-name,public-profile-url,picture-url,date-of-birth,phone-numbers,summary)');
|
$response = $this->api->profile('~:(id,first-name,last-name,public-profile-url,picture-url,email-address,date-of-birth,phone-numbers,summary)');
|
||||||
}
|
}
|
||||||
catch( LinkedInException $e ){
|
catch( LinkedInException $e ){
|
||||||
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
|
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
|
||||||
@@ -108,6 +108,9 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model
|
|||||||
$this->user->profile->lastName = (string) $data->{'last-name'};
|
$this->user->profile->lastName = (string) $data->{'last-name'};
|
||||||
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
||||||
|
|
||||||
|
$this->user->profile->email = (string) $data->{'email-address'};
|
||||||
|
$this->user->profile->emailVerified = (string) $data->{'email-address'};
|
||||||
|
|
||||||
$this->user->profile->photoURL = (string) $data->{'picture-url'};
|
$this->user->profile->photoURL = (string) $data->{'picture-url'};
|
||||||
$this->user->profile->profileURL = (string) $data->{'public-profile-url'};
|
$this->user->profile->profileURL = (string) $data->{'public-profile-url'};
|
||||||
$this->user->profile->description = (string) $data->{'summary'};
|
$this->user->profile->description = (string) $data->{'summary'};
|
||||||
|
@@ -1,117 +1,106 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Windows Live OAuth2 Class
|
||||||
|
*
|
||||||
|
* @package HybridAuth providers package
|
||||||
|
* @author Lukasz Koprowski <azram19@gmail.com>
|
||||||
|
* @version 0.2
|
||||||
|
* @license BSD License
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hybrid_Providers_Live provider adapter based on OAuth1 protocol
|
* Hybrid_Providers_Live - Windows Live provider adapter based on OAuth2 protocol
|
||||||
*
|
|
||||||
* Hybrid_Providers_Live use OAuthWrapHandler class provided by microsoft
|
|
||||||
*
|
|
||||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Live.html
|
|
||||||
*/
|
*/
|
||||||
class Hybrid_Providers_Live extends Hybrid_Provider_Model
|
class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2
|
||||||
{
|
{
|
||||||
|
// default permissions
|
||||||
|
public $scope = "wl.basic wl.emails wl.signin wl.share wl.birthday";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IDp wrappers initializer
|
* IDp wrappers initializer
|
||||||
*/
|
*/
|
||||||
function initialize()
|
function initialize()
|
||||||
{
|
{
|
||||||
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
|
parent::initialize();
|
||||||
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Application Specific Globals
|
// Provider api end-points
|
||||||
define( 'WRAP_CLIENT_ID' , $this->config["keys"]["id"] );
|
$this->api->api_base_url = "https://apis.live.net/v5.0/";
|
||||||
define( 'WRAP_CLIENT_SECRET', $this->config["keys"]["secret"] );
|
$this->api->authorize_url = "https://oauth.live.com/authorize";
|
||||||
define( 'WRAP_CALLBACK' , $this->endpoint );
|
$this->api->token_url = 'https://oauth.live.com/token';
|
||||||
define( 'WRAP_CHANNEL_URL' , Hybrid_Auth::$config["base_url"] . "?get=windows_live_channel" );
|
|
||||||
|
|
||||||
// Live URLs required for making requests.
|
$this->api->curl_authenticate_method = "GET";
|
||||||
define('WRAP_CONSENT_URL' , 'https://consent.live.com/Connect.aspx');
|
|
||||||
define('WRAP_ACCESS_URL' , 'https://consent.live.com/AccessToken.aspx');
|
|
||||||
define('WRAP_REFRESH_URL' , 'https://consent.live.com/RefreshToken.aspx');
|
|
||||||
|
|
||||||
require_once Hybrid_Auth::$config["path_libraries"] . "WindowsLive/OAuthWrapHandler.php";
|
|
||||||
|
|
||||||
$this->api = new OAuthWrapHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* begin login step
|
* grab the user profile from the api client
|
||||||
*/
|
|
||||||
function loginBegin()
|
|
||||||
{
|
|
||||||
$this->api->ExpireCookies();
|
|
||||||
|
|
||||||
Hybrid_Auth::redirect( WRAP_CONSENT_URL . "?wrap_client_id=" . WRAP_CLIENT_ID . "&wrap_callback=" . urlencode( WRAP_CALLBACK ) . "&wrap_scope=WL_Profiles.View" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finish login step
|
|
||||||
*/
|
|
||||||
function loginFinish()
|
|
||||||
{
|
|
||||||
$response = $this->api->ProcessRequest();
|
|
||||||
|
|
||||||
if ( ! isset( $response['c_uid'] ) || ! isset( $response['c_accessToken'] ) ){
|
|
||||||
throw new Exception( "Authentification failed! {$this->providerId} returned an invalid Token.", 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// set user as logged in
|
|
||||||
$this->setUserConnected();
|
|
||||||
|
|
||||||
# store access token
|
|
||||||
$this->token( "access_token", $response['c_accessToken'] );
|
|
||||||
|
|
||||||
# store the user id.
|
|
||||||
$this->token( "user_id", $response['c_uid'] );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load the user profile from the IDp api client
|
|
||||||
*/
|
*/
|
||||||
function getUserProfile()
|
function getUserProfile()
|
||||||
{
|
{
|
||||||
try{
|
$data = $this->api->get( "me" );
|
||||||
$access_token = $this->token( "access_token" );
|
|
||||||
|
|
||||||
$user_id = $this->token( "user_id" );
|
if ( ! isset( $data->id ) ){
|
||||||
|
throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 );
|
||||||
$info_url = 'http://apis.live.net/V4.1/cid-'. $user_id .'/Profiles/1-' . $user_id;
|
|
||||||
|
|
||||||
$response = $this->api->GET( $info_url, false, $access_token );
|
|
||||||
|
|
||||||
$response = json_decode( $response );
|
|
||||||
}
|
|
||||||
catch( Exception $e ){
|
|
||||||
throw new Exception( "User profile request failed! {$this->providerId} returned an error while requesting the user profile.", 6 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_object( $response ) ){
|
$this->user->profile->identifier = (property_exists($data,'id'))?$data->id:"";
|
||||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid user data.", 6 );
|
$this->user->profile->firstName = (property_exists($data,'first_name'))?$data->first_name:"";
|
||||||
}
|
$this->user->profile->lastName = (property_exists($data,'last_name'))?$data->last_name:"";
|
||||||
|
$this->user->profile->displayName = (property_exists($data,'name'))?trim( $data->name ):"";
|
||||||
|
$this->user->profile->gender = (property_exists($data,'gender'))?$data->gender:"";
|
||||||
|
|
||||||
$this->user->profile->identifier = $user_id;
|
//wl.basic
|
||||||
$this->user->profile->firstName = (string) $response->FirstName;
|
$this->user->profile->profileURL = (property_exists($data,'link'))?$data->link:"";
|
||||||
$this->user->profile->lastName = (string) $response->LastName;
|
|
||||||
$this->user->profile->profileURL = (string) $response->UxLink;
|
|
||||||
$this->user->profile->gender = (string) $response->Gender;
|
|
||||||
$this->user->profile->email = (string) $response->Emails[0]->Address;
|
|
||||||
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
|
||||||
|
|
||||||
if( $this->user->profile->gender == 1 ){
|
//wl.emails
|
||||||
$this->user->profile->gender = "female";
|
$this->user->profile->email = (property_exists($data,'emails'))?$data->emails->account:"";
|
||||||
}
|
$this->user->profile->emailVerified = (property_exists($data,'emails'))?$data->emails->account:"";
|
||||||
elseif( $this->user->profile->gender == 2 ){
|
|
||||||
$this->user->profile->gender = "male";
|
//wl.birthday
|
||||||
}
|
$this->user->profile->birthDay = (property_exists($data,'birth_day'))?$data->birth_day:"";
|
||||||
else{
|
$this->user->profile->birthMonth = (property_exists($data,'birth_month'))?$data->birth_month:"";
|
||||||
$this->user->profile->gender = "";
|
$this->user->profile->birthYear = (property_exists($data,'birth_year'))?$data->birth_year:"";
|
||||||
}
|
|
||||||
|
|
||||||
return $this->user->profile;
|
return $this->user->profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load the current logged in user contacts list from the IDp api client
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Windows Live api does not support retrieval of email addresses (only hashes :/) */
|
||||||
|
function getUserContacts()
|
||||||
|
{
|
||||||
|
$response = $this->api->get( 'me/contacts' );
|
||||||
|
|
||||||
|
if ( $this->api->http_code != 200 )
|
||||||
|
{
|
||||||
|
throw new Exception( 'User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $response->data && ( $response->error != 0 ) )
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$contacts = array();
|
||||||
|
|
||||||
|
foreach( $response->data as $item ) {
|
||||||
|
$uc = new Hybrid_User_Contact();
|
||||||
|
|
||||||
|
$uc->identifier = (property_exists($item,'id'))?$item->id:"";
|
||||||
|
$uc->displayName = (property_exists($item,'name'))?$item->name:"";
|
||||||
|
|
||||||
|
$contacts[] = $uc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $contacts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,32 +1,237 @@
|
|||||||
<?php
|
<?php
|
||||||
//!! planned to be replaced Y! openid by the oauth1 adapter soon
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yahoo OAuth Class
|
||||||
|
*
|
||||||
|
* @package HybridAuth providers package
|
||||||
|
* @author Lukasz Koprowski <azram19@gmail.com>
|
||||||
|
* @version 0.2
|
||||||
|
* @license BSD License
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hybrid_Providers_Yahoo provider adapter based on OAuth1 protocol
|
* Hybrid_Providers_Yahoo - Yahoo provider adapter based on OAuth1 protocol
|
||||||
*
|
*/
|
||||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Yahoo.html
|
class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OAuth1
|
||||||
*/
|
|
||||||
class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OpenID
|
|
||||||
{
|
{
|
||||||
var $openidIdentifier = "https://open.login.yahooapis.com/openid20/www.yahoo.com/xrds";
|
function initialize()
|
||||||
|
{
|
||||||
|
parent::initialize();
|
||||||
|
|
||||||
|
// Provider api end-points
|
||||||
|
$this->api->api_base_url = 'http://social.yahooapis.com/v1/';
|
||||||
|
$this->api->authorize_url = 'https://api.login.yahoo.com/oauth/v2/request_auth';
|
||||||
|
$this->api->request_token_url = 'https://api.login.yahoo.com/oauth/v2/get_request_token';
|
||||||
|
$this->api->access_token_url = 'https://api.login.yahoo.com/oauth/v2/get_token';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUserProfile()
|
||||||
|
{
|
||||||
|
$userId = $this->getCurrentUserId();
|
||||||
|
|
||||||
|
$parameters = array();
|
||||||
|
$parameters['format'] = 'json';
|
||||||
|
|
||||||
|
$response = $this->api->get( 'user/' . $userId . '/profile', $parameters );
|
||||||
|
|
||||||
|
if ( ! isset( $response->profile ) ){
|
||||||
|
throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $response->profile;
|
||||||
|
|
||||||
|
$this->user->profile->identifier = (property_exists($data,'guid'))?$data->guid:"";
|
||||||
|
$this->user->profile->firstName = (property_exists($data,'givenName'))?$data->givenName:"";
|
||||||
|
$this->user->profile->lastName = (property_exists($data,'familyName'))?$data->familyName:"";
|
||||||
|
$this->user->profile->displayName = (property_exists($data,'nickname'))?trim( $data->nickname ):"";
|
||||||
|
$this->user->profile->profileURL = (property_exists($data,'profileUrl'))?$data->profileUrl:"";
|
||||||
|
$this->user->profile->gender = (property_exists($data,'gender'))?$data->gender:"";
|
||||||
|
|
||||||
|
if( $this->user->profile->gender == "F" ){
|
||||||
|
$this->user->profile->gender = "female";
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $this->user->profile->gender == "M" ){
|
||||||
|
$this->user->profile->gender = "male";
|
||||||
|
}
|
||||||
|
|
||||||
|
if( isset($data->emails) ){
|
||||||
|
$email = "";
|
||||||
|
foreach( $data->emails as $v ){
|
||||||
|
if( isset($v->primary) && $v->primary ) {
|
||||||
|
$email = (property_exists($v,'handle'))?$v->handle:"";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->user->profile->email = $email;
|
||||||
|
$this->user->profile->emailVerified = $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->user->profile->age = (property_exists($data,'displayAge'))?$data->displayAge:"";
|
||||||
|
$this->user->profile->photoURL = (property_exists($data,'image'))?$data->image->imageUrl:"";
|
||||||
|
|
||||||
|
$this->user->profile->address = (property_exists($data,'location'))?$data->location:"";
|
||||||
|
$this->user->profile->language = (property_exists($data,'lang'))?$data->lang:"";
|
||||||
|
|
||||||
|
return $this->user->profile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finish login step
|
* load the user contacts
|
||||||
*/
|
*/
|
||||||
function loginFinish()
|
function getUserContacts()
|
||||||
{
|
{
|
||||||
parent::loginFinish();
|
$userId = $this->getCurrentUserId();
|
||||||
|
|
||||||
$this->user->profile->emailVerified = $this->user->profile->email;
|
$parameters = array();
|
||||||
|
$parameters['format'] = 'json';
|
||||||
|
$parameters['count'] = 'max';
|
||||||
|
|
||||||
|
$response = $this->api->get('user/' . $userId . '/contacts', $parameters);
|
||||||
|
|
||||||
// restore the user profile
|
if ( $this->api->http_code != 200 )
|
||||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
|
{
|
||||||
|
throw new Exception( 'User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$response->contacts->contact && ( $response->errcode != 0 ) )
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$contacts = array();
|
||||||
|
|
||||||
|
foreach( $response->contacts->contact as $item ) {
|
||||||
|
$uc = new Hybrid_User_Contact();
|
||||||
|
|
||||||
|
$uc->identifier = $this->selectGUID( $item );
|
||||||
|
$uc->email = $this->selectEmail( $item->fields );
|
||||||
|
$uc->displayName = $this->selectName( $item->fields );
|
||||||
|
$uc->photoURL = $this->selectPhoto( $item->fields );
|
||||||
|
|
||||||
|
$contacts[] = $uc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $contacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the user activity stream
|
||||||
|
*/
|
||||||
|
function getUserActivity( $stream )
|
||||||
|
{
|
||||||
|
$userId = $this->getCurrentUserId();
|
||||||
|
|
||||||
|
$parameters = array();
|
||||||
|
$parameters['format'] = 'json';
|
||||||
|
$parameters['count'] = 'max';
|
||||||
|
|
||||||
|
$response = $this->api->get('user/' . $userId . '/updates', $parameters);
|
||||||
|
|
||||||
|
if( ! $response->updates || $this->api->http_code != 200 )
|
||||||
|
{
|
||||||
|
throw new Exception( 'User activity request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$activities = array();
|
||||||
|
|
||||||
|
foreach( $response->updates as $item ){
|
||||||
|
$ua = new Hybrid_User_Activity();
|
||||||
|
|
||||||
|
$ua->id = (property_exists($item,'collectionID'))?$item->collectionID:"";
|
||||||
|
$ua->date = (property_exists($item,'lastUpdated'))?$item->lastUpdated:"";
|
||||||
|
$ua->text = (property_exists($item,'loc_longForm'))?$item->loc_longForm:"";
|
||||||
|
|
||||||
|
$ua->user->identifier = (property_exists($item,'profile_guid'))?$item->profile_guid:"";
|
||||||
|
$ua->user->displayName = (property_exists($item,'profile_nickname'))?$item->profile_nickname:"";
|
||||||
|
$ua->user->profileURL = (property_exists($item,'profile_profileUrl'))?$item->profile_profileUrl:"";
|
||||||
|
$ua->user->photoURL = (property_exists($item,'profile_displayImage'))?$item->profile_displayImage:"";
|
||||||
|
|
||||||
|
$activities[] = $ua;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $stream == "me" ){
|
||||||
|
$userId = $this->getCurrentUserId();
|
||||||
|
$my_activities = array();
|
||||||
|
|
||||||
|
foreach( $activities as $a ){
|
||||||
|
if( $a->user->identifier == $userId ){
|
||||||
|
$my_activities[] = $a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $my_activities;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $activities;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--
|
||||||
|
|
||||||
|
function select($vs, $t)
|
||||||
|
{
|
||||||
|
foreach( $vs as $v ){
|
||||||
|
if( $v->type == $t ) {
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectGUID( $v )
|
||||||
|
{
|
||||||
|
return (property_exists($v,'id'))?$v->id:"";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectName( $v )
|
||||||
|
{
|
||||||
|
$s = $this->select($v, 'name');
|
||||||
|
|
||||||
|
if( ! $s ){
|
||||||
|
$s = $this->select($v, 'nickname');
|
||||||
|
return ($s)?$s->value:"";
|
||||||
|
} else {
|
||||||
|
return ($s)?$s->value->givenName . " " . $s->value->familyName:"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectNickame( $v )
|
||||||
|
{
|
||||||
|
$s = $this->select($v, 'nickname');
|
||||||
|
return ($s)?$s:"";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectPhoto( $v )
|
||||||
|
{
|
||||||
|
$s = $this->select($v, 'guid');
|
||||||
|
return ($s)?(property_exists($s,'image')):"";
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectEmail( $v )
|
||||||
|
{
|
||||||
|
$s = $this->select($v, 'email');
|
||||||
|
return ($s)?$s->value:"";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCurrentUserId()
|
||||||
|
{
|
||||||
|
$parameters = array();
|
||||||
|
$parameters['format'] = 'json';
|
||||||
|
|
||||||
|
$response = $this->api->get( 'me/guid', $parameters );
|
||||||
|
|
||||||
|
if ( ! isset( $response->guid->value ) ){
|
||||||
|
throw new Exception( "User id request failed! {$this->providerId} returned an invalide response." );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->guid->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,13 +11,32 @@
|
|||||||
class Hybrid_Storage
|
class Hybrid_Storage
|
||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
if( ! session_id() ){
|
if ( ! session_id() ){
|
||||||
throw new Exception( "Hybriauth require the use of 'session_start()' at the start of your script", 1 );
|
if( ! session_start() ){
|
||||||
|
throw new Exception( "Hybridauth requires the use of 'session_start()' at the start of your script, which appears to be disabled.", 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->config( "php_session_id", session_id() );
|
||||||
|
$this->config( "version", Hybrid_Auth::$version );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($key, $expiration = false)
|
public function config($key, $value=null)
|
||||||
|
{
|
||||||
|
$key = strtolower( $key );
|
||||||
|
|
||||||
|
if( $value ){
|
||||||
|
$_SESSION["HA::CONFIG"][$key] = serialize( $value );
|
||||||
|
}
|
||||||
|
elseif( isset( $_SESSION["HA::CONFIG"][$key] ) ){
|
||||||
|
return unserialize( $_SESSION["HA::CONFIG"][$key] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key)
|
||||||
{
|
{
|
||||||
$key = strtolower( $key );
|
$key = strtolower( $key );
|
||||||
|
|
||||||
@@ -63,12 +82,16 @@ class Hybrid_Storage
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSessionData()
|
function getSessionData()
|
||||||
{
|
{
|
||||||
return serialize( $_SESSION["HA::STORE"] );
|
if( isset( $_SESSION["HA::STORE"] ) ){
|
||||||
|
return serialize( $_SESSION["HA::STORE"] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreSessionData( $sessiondata = NULL )
|
function restoreSessionData( $sessiondata = NULL )
|
||||||
{
|
{
|
||||||
$_SESSION["HA::STORE"] = unserialize( $sessiondata );
|
$_SESSION["HA::STORE"] = unserialize( $sessiondata );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
@@ -19,29 +19,23 @@ return
|
|||||||
"enabled" => #OPENID_ADAPTER_STATUS#
|
"enabled" => #OPENID_ADAPTER_STATUS#
|
||||||
),
|
),
|
||||||
|
|
||||||
"Yahoo" => array (
|
|
||||||
"enabled" => #YAHOO_ADAPTER_STATUS#
|
|
||||||
),
|
|
||||||
|
|
||||||
"AOL" => array (
|
"AOL" => array (
|
||||||
"enabled" => #AOL_ADAPTER_STATUS#
|
"enabled" => #AOL_ADAPTER_STATUS#
|
||||||
),
|
),
|
||||||
|
|
||||||
|
"Yahoo" => array (
|
||||||
|
"enabled" => #YAHOO_ADAPTER_STATUS#,
|
||||||
|
"keys" => array ( "id" => "#YAHOO_APPLICATION_KEY#", "secret" => "#YAHOO_APPLICATION_SECRET#" )
|
||||||
|
),
|
||||||
|
|
||||||
"Google" => array (
|
"Google" => array (
|
||||||
"enabled" => #GOOGLE_ADAPTER_STATUS#,
|
"enabled" => #GOOGLE_ADAPTER_STATUS#,
|
||||||
"keys" => array ( "id" => "#GOOGLE_APPLICATION_APP_ID#", "secret" => "#GOOGLE_APPLICATION_SECRET#" ),
|
"keys" => array ( "id" => "#GOOGLE_APPLICATION_APP_ID#", "secret" => "#GOOGLE_APPLICATION_SECRET#" )
|
||||||
"scope" => ""
|
|
||||||
),
|
),
|
||||||
|
|
||||||
"Facebook" => array (
|
"Facebook" => array (
|
||||||
"enabled" => #FACEBOOK_ADAPTER_STATUS#,
|
"enabled" => #FACEBOOK_ADAPTER_STATUS#,
|
||||||
"keys" => array ( "id" => "#FACEBOOK_APPLICATION_APP_ID#", "secret" => "#FACEBOOK_APPLICATION_SECRET#" ),
|
"keys" => array ( "id" => "#FACEBOOK_APPLICATION_APP_ID#", "secret" => "#FACEBOOK_APPLICATION_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" => ""
|
|
||||||
),
|
),
|
||||||
|
|
||||||
"Twitter" => array (
|
"Twitter" => array (
|
||||||
@@ -74,5 +68,5 @@ return
|
|||||||
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file"
|
// 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_mode" => false,
|
||||||
|
|
||||||
"debug_file" => "",
|
"debug_file" => ""
|
||||||
);
|
);
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// Modified
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2011 Facebook, Inc.
|
||||||
*
|
*
|
||||||
@@ -1266,4 +1268,49 @@ abstract class BaseFacebook
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
abstract protected function clearAllPersistentData();
|
abstract protected function clearAllPersistentData();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extending access_token expiration time through fb new endpoint
|
||||||
|
* returns an new access token which expires in 60 days
|
||||||
|
*
|
||||||
|
* http://developers.facebook.com/roadmap/offline-access-removal/#extend_token
|
||||||
|
* http://stackoverflow.com/a/9035036/1106794
|
||||||
|
*/
|
||||||
|
function extendedAccessToken( $old_access_token )
|
||||||
|
{
|
||||||
|
// Make a OAuth Request.
|
||||||
|
try {
|
||||||
|
$params = array(
|
||||||
|
'client_id' => $this->getAppId(),
|
||||||
|
'client_secret' => $this->getAppSecret(),
|
||||||
|
'grant_type' => 'fb_exchange_token',
|
||||||
|
'fb_exchange_token' => $old_access_token,
|
||||||
|
);
|
||||||
|
|
||||||
|
$response = $this->_oauthRequest( $this->getUrl( 'graph', '/oauth/access_token' ), $params );
|
||||||
|
|
||||||
|
// print_r( array( $this->getUrl( 'graph', '/oauth/access_token' ), $params, $response ) );
|
||||||
|
}
|
||||||
|
catch ( FacebookApiException $e ) {
|
||||||
|
// most likely that user very recently revoked authorization.
|
||||||
|
// In any event, we don't have an access token, so say so.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($response)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response_params = array();
|
||||||
|
|
||||||
|
parse_str($response, $response_params);
|
||||||
|
|
||||||
|
if (!isset($response_params['access_token'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response_params['access_token'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// http://code.google.com/p/simple-linkedinphp/
|
// http://code.google.com/p/simple-linkedinphp/
|
||||||
// 3.2.0 - November 29, 2011
|
// 3.2.0 - November 29, 2011
|
||||||
|
// hacked into the code to handel new scope (r_basicprofile+r_emailaddress) - until Paul update linkedinphp library!
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file defines the 'LinkedIn' class. This class is designed to be a
|
* This file defines the 'LinkedIn' class. This class is designed to be a
|
||||||
@@ -121,7 +122,8 @@ class LinkedIn {
|
|||||||
const _URL_ACCESS = 'https://api.linkedin.com/uas/oauth/accessToken';
|
const _URL_ACCESS = 'https://api.linkedin.com/uas/oauth/accessToken';
|
||||||
const _URL_API = 'https://api.linkedin.com';
|
const _URL_API = 'https://api.linkedin.com';
|
||||||
const _URL_AUTH = 'https://www.linkedin.com/uas/oauth/authenticate?oauth_token=';
|
const _URL_AUTH = 'https://www.linkedin.com/uas/oauth/authenticate?oauth_token=';
|
||||||
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken';
|
// const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken';
|
||||||
|
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress';
|
||||||
const _URL_REVOKE = 'https://api.linkedin.com/uas/oauth/invalidateToken';
|
const _URL_REVOKE = 'https://api.linkedin.com/uas/oauth/invalidateToken';
|
||||||
|
|
||||||
// Library version
|
// Library version
|
||||||
@@ -2636,4 +2638,4 @@ class LinkedIn {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// A service client for the OAuth 1/1.0a flow.
|
// A service client for the OAuth 1/1.0a flow.
|
||||||
@@ -25,6 +25,7 @@ class OAuth1Client{
|
|||||||
public $curl_ssl_verifypeer = false;
|
public $curl_ssl_verifypeer = false;
|
||||||
public $curl_auth_header = true;
|
public $curl_auth_header = true;
|
||||||
public $curl_useragent = "OAuth/1 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
|
public $curl_useragent = "OAuth/1 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
|
||||||
|
public $curl_proxy = null;
|
||||||
|
|
||||||
//--
|
//--
|
||||||
|
|
||||||
@@ -173,7 +174,11 @@ class OAuth1Client{
|
|||||||
curl_setopt( $ci, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer );
|
curl_setopt( $ci, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer );
|
||||||
curl_setopt( $ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader') );
|
curl_setopt( $ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader') );
|
||||||
curl_setopt( $ci, CURLOPT_HEADER , FALSE );
|
curl_setopt( $ci, CURLOPT_HEADER , FALSE );
|
||||||
|
|
||||||
|
if($this->curl_proxy){
|
||||||
|
curl_setopt( $ci, CURLOPT_PROXY , $this->curl_proxy);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($method){
|
switch ($method){
|
||||||
case 'POST':
|
case 'POST':
|
||||||
curl_setopt( $ci, CURLOPT_POST, TRUE );
|
curl_setopt( $ci, CURLOPT_POST, TRUE );
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*!
|
/*!
|
||||||
* HybridAuth
|
* HybridAuth
|
||||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// A service client for the OAuth 2 flow.
|
// A service client for the OAuth 2 flow.
|
||||||
@@ -16,7 +16,7 @@ class OAuth2Client
|
|||||||
|
|
||||||
public $client_id = "" ;
|
public $client_id = "" ;
|
||||||
public $client_secret = "" ;
|
public $client_secret = "" ;
|
||||||
public $redirect_uri = "" ;
|
public $redirect_uri = "" ;
|
||||||
public $access_token = "" ;
|
public $access_token = "" ;
|
||||||
public $refresh_token = "" ;
|
public $refresh_token = "" ;
|
||||||
|
|
||||||
@@ -25,13 +25,15 @@ class OAuth2Client
|
|||||||
|
|
||||||
//--
|
//--
|
||||||
|
|
||||||
public $sign_token_name = "access_token";
|
public $sign_token_name = "access_token";
|
||||||
public $decode_json = true;
|
public $decode_json = true;
|
||||||
public $curl_time_out = 30;
|
public $curl_time_out = 30;
|
||||||
public $curl_connect_time_out = 30;
|
public $curl_connect_time_out = 30;
|
||||||
public $curl_ssl_verifypeer = false;
|
public $curl_ssl_verifypeer = false;
|
||||||
public $curl_header = array();
|
public $curl_header = array();
|
||||||
public $curl_useragent = "OAuth/2 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
|
public $curl_useragent = "OAuth/2 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
|
||||||
|
public $curl_authenticate_method = "POST";
|
||||||
|
public $curl_proxy = null;
|
||||||
|
|
||||||
//--
|
//--
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ class OAuth2Client
|
|||||||
return $this->authorize_url . "?" . http_build_query( $params );
|
return $this->authorize_url . "?" . http_build_query( $params );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authenticate( $code )
|
public function authenticate( $code )
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = array(
|
||||||
"client_id" => $this->client_id,
|
"client_id" => $this->client_id,
|
||||||
@@ -71,8 +73,9 @@ class OAuth2Client
|
|||||||
"redirect_uri" => $this->redirect_uri,
|
"redirect_uri" => $this->redirect_uri,
|
||||||
"code" => $code
|
"code" => $code
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->request( $this->token_url, $params, "POST" );
|
$response = $this->request( $this->token_url, $params, $this->curl_authenticate_method );
|
||||||
|
|
||||||
$response = $this->parseRequestResult( $response );
|
$response = $this->parseRequestResult( $response );
|
||||||
|
|
||||||
if( ! $response || ! isset( $response->access_token ) ){
|
if( ! $response || ! isset( $response->access_token ) ){
|
||||||
@@ -87,7 +90,7 @@ class OAuth2Client
|
|||||||
$this->access_token_expires_at = time() + $response->expires_in;
|
$this->access_token_expires_at = time() + $response->expires_in;
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authenticated()
|
public function authenticated()
|
||||||
{
|
{
|
||||||
@@ -203,13 +206,16 @@ class OAuth2Client
|
|||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , $this->curl_ssl_verifypeer );
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , $this->curl_ssl_verifypeer );
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER , $this->curl_header );
|
curl_setopt($ch, CURLOPT_HTTPHEADER , $this->curl_header );
|
||||||
|
|
||||||
|
if($this->curl_proxy){
|
||||||
|
curl_setopt( $ch, CURLOPT_PROXY , $this->curl_proxy);
|
||||||
|
}
|
||||||
|
|
||||||
if( $type == "POST" ){
|
if( $type == "POST" ){
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
if($params) curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
|
if($params) curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|
||||||
Hybrid_Logger::debug( "OAuth2Client::request(). dump request info: ", serialize( curl_getinfo($ch) ) );
|
Hybrid_Logger::debug( "OAuth2Client::request(). dump request info: ", serialize( curl_getinfo($ch) ) );
|
||||||
Hybrid_Logger::debug( "OAuth2Client::request(). dump request result: ", serialize( $response ) );
|
Hybrid_Logger::debug( "OAuth2Client::request(). dump request result: ", serialize( $response ) );
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ class LightOpenID
|
|||||||
, $data;
|
, $data;
|
||||||
private $identity, $claimed_id;
|
private $identity, $claimed_id;
|
||||||
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
|
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
|
||||||
, $ax = false, $sreg = false, $setup_url = null, $headers = array();
|
, $ax = false, $sreg = false, $setup_url = null, $headers = array(), $proxy = null;
|
||||||
static protected $ax_to_sreg = array(
|
static protected $ax_to_sreg = array(
|
||||||
'namePerson/friendly' => 'nickname',
|
'namePerson/friendly' => 'nickname',
|
||||||
'contact/email' => 'email',
|
'contact/email' => 'email',
|
||||||
@@ -34,8 +34,9 @@ class LightOpenID
|
|||||||
'pref/timezone' => 'timezone',
|
'pref/timezone' => 'timezone',
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct($host)
|
function __construct($host, $proxy)
|
||||||
{
|
{
|
||||||
|
$this->proxy = $proxy;
|
||||||
$this->trustRoot = (strpos($host, '://') ? $host : 'http://' . $host);
|
$this->trustRoot = (strpos($host, '://') ? $host : 'http://' . $host);
|
||||||
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
|
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
|
||||||
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
|
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
|
||||||
@@ -126,7 +127,9 @@ class LightOpenID
|
|||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
|
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
|
||||||
|
if($this->proxy){
|
||||||
|
curl_setopt( $curl, CURLOPT_PROXY, $this->proxy);
|
||||||
|
}
|
||||||
if($this->verify_peer !== null) {
|
if($this->verify_peer !== null) {
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
|
||||||
if($this->capath) {
|
if($this->capath) {
|
||||||
@@ -244,6 +247,9 @@ class LightOpenID
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
$url = $url . ($params ? '?' . $params : '');
|
$url = $url . ($params ? '?' . $params : '');
|
||||||
|
if($this->proxy){
|
||||||
|
$opts['http']['proxy'] = 'http://' . $this->proxy;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'POST':
|
case 'POST':
|
||||||
$opts = array(
|
$opts = array(
|
||||||
@@ -256,6 +262,9 @@ class LightOpenID
|
|||||||
'CN_match' => parse_url($url, PHP_URL_HOST),
|
'CN_match' => parse_url($url, PHP_URL_HOST),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if($this->proxy){
|
||||||
|
$opts['http']['proxy'] = 'http://' . $this->proxy;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'HEAD':
|
case 'HEAD':
|
||||||
# We want to send a HEAD request,
|
# We want to send a HEAD request,
|
||||||
@@ -312,7 +321,7 @@ class LightOpenID
|
|||||||
$this->headers = $this->parse_header_array($http_response_header, $update_claimed_id);
|
$this->headers = $this->parse_header_array($http_response_header, $update_claimed_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_get_contents($url, false, $context);
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
|
protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
|
||||||
|
Reference in New Issue
Block a user