From 23bf0d6a17d770356aea1cd8c4bfc4f6d8bf9a45 Mon Sep 17 00:00:00 2001 From: thisgun Date: Thu, 26 Oct 2017 10:19:49 +0900 Subject: [PATCH] =?UTF-8?q?=EC=86=8C=EC=85=9C=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/social_login.extend.php | 10 ++++ plugin/social/config.php | 1 + plugin/social/includes/functions.php | 14 +++++- plugin/social/includes/g5_endpoint.php | 50 ++++++++++---------- plugin/social/includes/g5_endpoint_class.php | 32 +++++++++++++ plugin/social/index.php | 4 +- 6 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 plugin/social/includes/g5_endpoint_class.php diff --git a/extend/social_login.extend.php b/extend/social_login.extend.php index cf0a2a835..44a6a0154 100644 --- a/extend/social_login.extend.php +++ b/extend/social_login.extend.php @@ -6,6 +6,16 @@ $g5['social_profile_table'] = G5_TABLE_PREFIX.'member_social_profiles'; //플러그인 폴더 이름 및 스킨 폴더 이름 define('G5_SOCIAL_LOGIN_DIR', 'social'); + +// 소셜로그인 login_start 파라미터 이름입니다. 기본값은 hauth.start +define('G5_SOCIAL_LOGIN_START_PARAM', 'hauth.start'); + +// 소셜로그인 login_done 파라미터 이름입니다. 기본값은 hauth.done +define('G5_SOCIAL_LOGIN_DONE_PARAM', 'hauth.done'); + +// 소셜로그인 G5_SOCIAL_LOGIN_URL 값의 끝에 해당 문자열을 더합니다. +define('G5_SOCIAL_LOGIN_ADD_URL', '/'); + define('G5_SOCIAL_LOGIN_PATH', G5_PLUGIN_PATH.'/'.G5_SOCIAL_LOGIN_DIR); define('G5_SOCIAL_LOGIN_URL', G5_PLUGIN_URL.'/'.G5_SOCIAL_LOGIN_DIR); diff --git a/plugin/social/config.php b/plugin/social/config.php index 247e396bb..c6816b840 100644 --- a/plugin/social/config.php +++ b/plugin/social/config.php @@ -1,4 +1,5 @@ getSessionData(); - return $g5['hybrid_auth']->authenticate($provider); + if( defined('G5_SOCIAL_LOGIN_START_PARAM') && G5_SOCIAL_LOGIN_START_PARAM === 'hauth.start' && G5_SOCIAL_LOGIN_DONE_PARAM === 'hauth.done' ){ + return $g5['hybrid_auth']->authenticate($provider); + } + + $base_url = G5_SOCIAL_LOGIN_URL.G5_SOCIAL_LOGIN_ADD_URL; + $hauth_time = time(); + + $connect_data = array( + 'login_start' => $base_url . ( strpos($base_url, '?') ? '&' : '?' ) . G5_SOCIAL_LOGIN_START_PARAM.'='.$provider.'&hauth.time='.$hauth_time, + 'login_done' => $base_url . ( strpos($base_url, '?') ? '&' : '?' ) . G5_SOCIAL_LOGIN_DONE_PARAM.'='.$provider, + ); + + return $g5['hybrid_auth']->authenticate($provider, $connect_data); } function social_before_join_check($url=''){ diff --git a/plugin/social/includes/g5_endpoint.php b/plugin/social/includes/g5_endpoint.php index 29c8f4304..c9df2435f 100644 --- a/plugin/social/includes/g5_endpoint.php +++ b/plugin/social/includes/g5_endpoint.php @@ -1,32 +1,32 @@ dieError( "412 Precondition Failed", $e->getMessage(), $e ); - } +class G5_Hybrid_Authentication { + + public static function hybridauth_endpoint() { + + require_once( G5_SOCIAL_LOGIN_PATH.'/Hybrid/Auth.php' ); + require_once( G5_SOCIAL_LOGIN_PATH.'/Hybrid/Endpoint.php' ); + require_once( G5_SOCIAL_LOGIN_PATH.'/includes/g5_endpoint_class.php' ); + + if( defined('G5_SOCIAL_LOGIN_START_PARAM') && G5_SOCIAL_LOGIN_START_PARAM !== 'hauth.start' && isset($_REQUEST[G5_SOCIAL_LOGIN_START_PARAM]) ){ + $_REQUEST['hauth.start'] = preg_replace('/[^a-zA-Z0-9\-\._]/i', '', $_REQUEST[G5_SOCIAL_LOGIN_START_PARAM]); + } + + if( defined('G5_SOCIAL_LOGIN_DONE_PARAM') && G5_SOCIAL_LOGIN_DONE_PARAM !== 'hauth.done' && isset($_REQUEST[G5_SOCIAL_LOGIN_DONE_PARAM]) ){ + $_REQUEST['hauth.done'] = preg_replace('/[^a-zA-Z0-9\-\._]/i', '', $_REQUEST[G5_SOCIAL_LOGIN_DONE_PARAM]); + } + + /* + $key = 'hauth.' . $action; // either `hauth_start` or `hauth_done` + + $_REQUEST[ $key ] = $provider; // provider will be something like `facebook` or `google` + */ + + G5_Hybrid_Endpoint::process(); } - protected function processAuthDone() - { - try { - parent::processAuthDone(); - } - catch( Exception $e ){ - $this->dieError( "410 Gone", $e->getMessage(), $e ); - } - } - - public function dieError( $code, $message, $e ) - { - $get_error = $message; - include_once(G5_SOCIAL_LOGIN_PATH.'/error.php'); - die(); - } } + ?> \ No newline at end of file diff --git a/plugin/social/includes/g5_endpoint_class.php b/plugin/social/includes/g5_endpoint_class.php new file mode 100644 index 000000000..29c8f4304 --- /dev/null +++ b/plugin/social/includes/g5_endpoint_class.php @@ -0,0 +1,32 @@ +dieError( "412 Precondition Failed", $e->getMessage(), $e ); + } + } + + protected function processAuthDone() + { + try { + parent::processAuthDone(); + } + catch( Exception $e ){ + $this->dieError( "410 Gone", $e->getMessage(), $e ); + } + } + + public function dieError( $code, $message, $e ) + { + $get_error = $message; + include_once(G5_SOCIAL_LOGIN_PATH.'/error.php'); + die(); + } +} +?> \ No newline at end of file diff --git a/plugin/social/index.php b/plugin/social/index.php index 6b98177fc..e974ae9ee 100644 --- a/plugin/social/index.php +++ b/plugin/social/index.php @@ -10,8 +10,6 @@ // ------------------------------------------------------------------------ include_once('_common.php'); -require_once( "Hybrid/Auth.php" ); -require_once( "Hybrid/Endpoint.php" ); require_once( "includes/g5_endpoint.php" ); -G5_Hybrid_Endpoint::process(); \ No newline at end of file +G5_Hybrid_Authentication::hybridauth_endpoint(); \ No newline at end of file