aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoseph Warner <hardolaf@hardolaf.com>2013-07-18 12:50:42 -0400
committerJoseph Warner <hardolaf@hardolaf.com>2013-07-18 12:51:53 -0400
commit2faaa7f63cd45244cd536b507325e65c5f085b39 (patch)
treead900393506c24472f64a0b39a70e5b019005964 /phpBB
parentbbbe442c425d333d7fea35b03217d0f222f1e2cc (diff)
downloadforums-2faaa7f63cd45244cd536b507325e65c5f085b39.tar
forums-2faaa7f63cd45244cd536b507325e65c5f085b39.tar.gz
forums-2faaa7f63cd45244cd536b507325e65c5f085b39.tar.bz2
forums-2faaa7f63cd45244cd536b507325e65c5f085b39.tar.xz
forums-2faaa7f63cd45244cd536b507325e65c5f085b39.zip
[feature/oauth] Update service files + check for existing links
PHPBB3-11673
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/config/auth_providers.yml3
-rw-r--r--phpBB/config/tables.yml3
-rw-r--r--phpBB/phpbb/auth/provider/oauth/oauth.php32
3 files changed, 29 insertions, 9 deletions
diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml
index 98b51fb917..b7486eabf4 100644
--- a/phpBB/config/auth_providers.yml
+++ b/phpBB/config/auth_providers.yml
@@ -42,7 +42,8 @@ services:
- @config
- @request
- @user
- - %tables.auth_provider_oauth%
+ - %tables.auth_provider_oauth_token_storage%
+ - %tables.auth_provider_oauth_account_assoc%
- @auth.provider.oauth.service_collection
tags:
- { name: auth.provider }
diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml
index 48098ba8c2..e12720023d 100644
--- a/phpBB/config/tables.yml
+++ b/phpBB/config/tables.yml
@@ -1,5 +1,6 @@
parameters:
- tables.auth_provider_oauth: %core.table_prefix%auth_provider_oauth
+ tables.auth_provider_oauth_token_storage: %core.table_prefix%auth_provider_oauth_token_storage
+ tables.auth_provider_oauth_account_assoc: %core.table_prefix%auth_provider_oauth_account_assoc
tables.config: %core.table_prefix%config
tables.config_text: %core.table_prefix%config_text
tables.ext: %core.table_prefix%ext
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php
index fc6fce3db0..afaae8a8ea 100644
--- a/phpBB/phpbb/auth/provider/oauth/oauth.php
+++ b/phpBB/phpbb/auth/provider/oauth/oauth.php
@@ -58,7 +58,14 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
*
* @var string
*/
- protected $auth_provider_oauth_table;
+ protected $auth_provider_oauth_token_storage_table;
+
+ /**
+ * OAuth account association table
+ *
+ * @var string
+ */
+ protected $auth_provider_oauth_token_account_assoc;
/**
* Cached services once they has been created
@@ -88,16 +95,18 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
* @param phpbb_config $config
* @param phpbb_request $request
* @param phpbb_user $user
- * @param string $auth_provider_oauth_table
+ * @param string $auth_provider_oauth_token_storage_table
+ * @param string $auth_provider_oauth_token_account_assoc
* @param phpbb_auth_provider_oauth_service_interface $service_providers
*/
- public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_table, phpbb_auth_provider_oauth_service_interface $service_providers)
+ public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_auth_provider_oauth_service_interface $service_providers)
{
$this->db = $db;
$this->config = $config;
$this->request = $request;
$this->user = $user;
- $this->auth_provider_oauth_table = $auth_provider_oauth_table;
+ $this->auth_provider_oauth_token_storage_table = $auth_provider_oauth_token_storage_table;
+ $this->auth_provider_oauth_token_account_assoc = $auth_provider_oauth_token_account_assoc;
$this->service_providers = $service_providers;
$this->services = array();
}
@@ -123,15 +132,24 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
// Get the service credentials for the given service
$service_credentials = $this->services[$service_name]->get_credentials();
- $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table);
+ $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table);
$service = $this->get_service($service_name, $storage, $service_credentials, $this->services[$service_name]->get_auth_scope());
if ($this->request->is_set('code', phpbb_request_interface::GET))
{
$this->services[$service_name]->set_external_service_provider($service);
- $result = $this->services[$service_name]->perform_auth_login();
+ $unique_id = $this->services[$service_name]->perform_auth_login();
- // Perform authentication
+ // Check to see if this provider is already assosciated with an account
+ $data = array(
+ 'oauth_provider' => $service_name,
+ 'oauth_provider_id' => $unique_id
+ );
+ $sql = 'SELECT user_id FROM' . $this->auth_provider_oauth_token_account_assoc . '
+ WHERE ' . $this->db->sql_build_array('SELECT', $data);
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
} else {
$url = $service->getAuthorizationUri();
// TODO: modify $url for the appropriate return points