diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 4d402e71f2..ead540c953 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -42,5 +42,6 @@ services: - @config - @request - @user + - %tables.auth_provider_oauth% tags: - { name: auth.provider } diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index fdb448f4e0..48098ba8c2 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,4 +1,5 @@ parameters: + tables.auth_provider_oauth: %core.table_prefix%auth_provider_oauth tables.config: %core.table_prefix%config tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index 4bf52e2ced..90185e5f5a 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -49,6 +49,13 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface */ protected $service_name; + /** + * OAuth token table + * + * @var string + */ + protected $auth_provider_oauth_table; + /** * @var object|TokenInterface */ @@ -57,15 +64,17 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface /** * Creates token storage for phpBB. * - * @param phpbb_db_driver $db - * @param phpbb_user $user - * @param string $service_name + * @param phpbb_db_driver $db + * @param phpbb_user $user + * @param string $service_name + * @param string $auth_provider_oauth_table */ - public function __construct(phpbb_db_driver $db, phpbb_user $user, $service_name) + public function __construct(phpbb_db_driver $db, phpbb_user $user, $service_name, $auth_provider_oauth_table) { $this->db = $db; $this->user = $user; $this->service_name = $service_name; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; } /** @@ -77,7 +86,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return $this->token; } - $sql = 'SELECT oauth_token FROM ' . AUTH_PROVIDER_OAUTH . + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . $db->sql_build_array('SELECT', array( 'user_id' => $this->user->data['user_id'], 'oauth_provider' => $this->service_name, @@ -111,11 +120,12 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface { $this->cachedToken = $token; - $sql = 'INSERT INTO ' . AUTH_PROVIDER_OAUTH . ' ' . $this->db->sql_build_array('INSERT', array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - 'oauth_token' => serialize($token), - )); + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' ' . + $this->db->sql_build_array('INSERT', array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + 'oauth_token' => serialize($token), + )); $this->db->sql_query($sql); } @@ -128,7 +138,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return true; } - $sql = 'SELECT oauth_token FROM ' . AUTH_PROVIDER_OAUTH . + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . $db->sql_build_array('SELECT', array( 'user_id' => $this->user->data['user_id'], 'oauth_provider' => $this->service_name, @@ -152,7 +162,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface { $this->cachedToken = null; - $sql = 'DELETE FROM ' . AUTH_PROVIDER_OAUTH . 'WHERE user_id = ' . $this->user->data['user_id'] . + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . 'WHERE user_id = ' . $this->user->data['user_id'] . ' AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); $this->db->sql_query($sql); } diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index ee18c0f60d..c7f60c5ae4 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -53,6 +53,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $user; + /** + * OAuth token table + * + * @var string + */ + protected $auth_provider_oauth_table; + /** * Cached service once it has been created * @@ -70,17 +77,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base /** * OAuth Authentication Constructor * - * @param phpbb_db_driver $db - * @param phpbb_config $config - * @param phpbb_request $request - * @param phpbb_user $user + * @param phpbb_db_driver $db + * @param phpbb_config $config + * @param phpbb_request $request + * @param phpbb_user $user + * @param string $auth_provider_oauth_table */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_table) { $this->db = $db; $this->config = $config; $this->request = $request; $this->user = $user; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; } /** @@ -177,7 +186,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service; } - $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name); + $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); $current_uri = $this->get_current_uri();