mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
[feature/oauth] Use DB for OAuth token storage
PHPBB3-11673
This commit is contained in:
parent
37f099b014
commit
24bf333e16
@ -42,6 +42,5 @@ services:
|
||||
- @config
|
||||
- @request
|
||||
- @user
|
||||
- @cache.driver
|
||||
tags:
|
||||
- { name: auth.provider }
|
||||
|
@ -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'),
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,13 +53,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
|
||||
*
|
||||
@ -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();
|
||||
|
||||
|
42
phpBB/includes/db/migration/data/310/auth_provider_oauth.php
Normal file
42
phpBB/includes/db/migration/data/310/auth_provider_oauth.php
Normal file
@ -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',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user