aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoseph Warner <hardolaf@hardolaf.com>2013-07-13 16:51:38 -0400
committerJoseph Warner <hardolaf@hardolaf.com>2013-07-14 14:22:42 -0400
commit24bf333e161332ddd589831228e35ad9eb1e8f18 (patch)
tree1f75cd05e829dd8e59c93c5dca914fea3b97a95a /phpBB
parent37f099b014ea34378096c50cf898c060bd3f0d42 (diff)
downloadforums-24bf333e161332ddd589831228e35ad9eb1e8f18.tar
forums-24bf333e161332ddd589831228e35ad9eb1e8f18.tar.gz
forums-24bf333e161332ddd589831228e35ad9eb1e8f18.tar.bz2
forums-24bf333e161332ddd589831228e35ad9eb1e8f18.tar.xz
forums-24bf333e161332ddd589831228e35ad9eb1e8f18.zip
[feature/oauth] Use DB for OAuth token storage
PHPBB3-11673
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/config/auth_providers.yml1
-rw-r--r--phpBB/develop/create_schema_files.php9
-rw-r--r--phpBB/includes/auth/oauth/token_storage.php18
-rw-r--r--phpBB/includes/auth/provider/oauth.php13
-rw-r--r--phpBB/includes/db/migration/data/310/auth_provider_oauth.php42
5 files changed, 66 insertions, 17 deletions
diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml
index 78c799ffb1..4d402e71f2 100644
--- a/phpBB/config/auth_providers.yml
+++ b/phpBB/config/auth_providers.yml
@@ -42,6 +42,5 @@ services:
- @config
- @request
- @user
- - @cache.driver
tags:
- { name: auth.provider }
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 316fbe19e6..f3eeb31c28 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -923,6 +923,15 @@ function get_schema_struct()
),
);
+ $schemda_data['auth_provider_oauth'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0), // phpbb_users.user_id
+ 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider
+ 'oauth_token' => array('TEXT_UNI'), // Serialized token
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'oauth_provider'),
+ );
+
$schema_data['phpbb_banlist'] = array(
'COLUMNS' => array(
'ban_id' => array('UINT', NULL, 'auto_increment'),
diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php
index 2d3c58d25a..b658333900 100644
--- a/phpBB/includes/auth/oauth/token_storage.php
+++ b/phpBB/includes/auth/oauth/token_storage.php
@@ -28,9 +28,16 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
/**
* Cache driver.
*
- * @var phpbb_cache_driver_interface
+ * @var phpbb_db_driver
*/
- protected $driver;
+ protected $db;
+
+ /**
+ * Name of the OAuth provider
+ *
+ * @var string
+ */
+ protected $service_name;
/**
* @var object|TokenInterface
@@ -40,11 +47,12 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
/**
* Creates token storage for phpBB.
*
- * @param phpbb_cache_driver_interface $driver The cache driver
+ * @param phpbb_db_driver $db
*/
- public function __construct(phpbb_cache_driver_interface $driver)
+ public function __construct(phpbb_db_driver $db, $service_name)
{
- $this->driver = $driver;
+ $this->db = $db;
+ $this->service_name = $service_name;
}
/**
diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php
index 267105e6b6..55a12211d6 100644
--- a/phpBB/includes/auth/provider/oauth.php
+++ b/phpBB/includes/auth/provider/oauth.php
@@ -54,13 +54,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
protected $user;
/**
- * Cache driver.
- *
- * @var phpbb_cache_driver_interface
- */
- protected $driver;
-
- /**
* Cached service once it has been created
*
* @var \OAuth\Common\Service\ServiceInterface|null
@@ -81,15 +74,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
* @param phpbb_config $config
* @param phpbb_request $request
* @param phpbb_user $user
- * @param phpbb_cache_driver_interface $driver
*/
- public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, phpbb_cache_driver_interface $driver)
+ public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user)
{
$this->db = $db;
$this->config = $config;
$this->request = $request;
$this->user = $user;
- $this->driver = $driver;
}
/**
@@ -186,7 +177,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
return $this->service;
}
- $storage = new phpbb_auth_oauth_token_storage($this->driver);
+ $storage = new phpbb_auth_oauth_token_storage($this->db, $service_name);
$current_uri = $this->get_current_uri();
diff --git a/phpBB/includes/db/migration/data/310/auth_provider_oauth.php b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php
new file mode 100644
index 0000000000..6239cf97bc
--- /dev/null
+++ b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* @package migration
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
+*
+*/
+
+class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration
+{
+ public function effectively_installed()
+ {
+ return $this->db_tools->sql_table_exists($this->table_prefix . 'auth_provider_oauth');
+ }
+
+ public function update_schema()
+ {
+ return array(
+ 'add_tables' => array(
+ $this->table_prefix . 'auth_provider_oauth' => array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0), // phpbb_users.user_id
+ 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider
+ 'oauth_token' => array('TEXT_UNI'), // Serialized token
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'oauth_provider'),
+ ),
+ ),
+
+ );
+ }
+
+ public function revert_schema()
+ {
+ return array(
+ 'drop_tables' => array(
+ $this->table_prefix . 'auth_provider_oauth',
+ ),
+ );
+ }
+}