mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/oauth] Pass table in constructor
PHPBB3-11673
This commit is contained in:
parent
69e1588655
commit
5942eac5da
4 changed files with 39 additions and 18 deletions
|
@ -42,5 +42,6 @@ services:
|
||||||
- @config
|
- @config
|
||||||
- @request
|
- @request
|
||||||
- @user
|
- @user
|
||||||
|
- %tables.auth_provider_oauth%
|
||||||
tags:
|
tags:
|
||||||
- { name: auth.provider }
|
- { name: auth.provider }
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
parameters:
|
parameters:
|
||||||
|
tables.auth_provider_oauth: %core.table_prefix%auth_provider_oauth
|
||||||
tables.config: %core.table_prefix%config
|
tables.config: %core.table_prefix%config
|
||||||
tables.config_text: %core.table_prefix%config_text
|
tables.config_text: %core.table_prefix%config_text
|
||||||
tables.ext: %core.table_prefix%ext
|
tables.ext: %core.table_prefix%ext
|
||||||
|
|
|
@ -49,6 +49,13 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
|
||||||
*/
|
*/
|
||||||
protected $service_name;
|
protected $service_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth token table
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $auth_provider_oauth_table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object|TokenInterface
|
* @var object|TokenInterface
|
||||||
*/
|
*/
|
||||||
|
@ -57,15 +64,17 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
|
||||||
/**
|
/**
|
||||||
* Creates token storage for phpBB.
|
* Creates token storage for phpBB.
|
||||||
*
|
*
|
||||||
* @param phpbb_db_driver $db
|
* @param phpbb_db_driver $db
|
||||||
* @param phpbb_user $user
|
* @param phpbb_user $user
|
||||||
* @param string $service_name
|
* @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->db = $db;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->service_name = $service_name;
|
$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;
|
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(
|
$db->sql_build_array('SELECT', array(
|
||||||
'user_id' => $this->user->data['user_id'],
|
'user_id' => $this->user->data['user_id'],
|
||||||
'oauth_provider' => $this->service_name,
|
'oauth_provider' => $this->service_name,
|
||||||
|
@ -111,11 +120,12 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
|
||||||
{
|
{
|
||||||
$this->cachedToken = $token;
|
$this->cachedToken = $token;
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . AUTH_PROVIDER_OAUTH . ' ' . $this->db->sql_build_array('INSERT', array(
|
$sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' ' .
|
||||||
'user_id' => $this->user->data['user_id'],
|
$this->db->sql_build_array('INSERT', array(
|
||||||
'oauth_provider' => $this->service_name,
|
'user_id' => $this->user->data['user_id'],
|
||||||
'oauth_token' => serialize($token),
|
'oauth_provider' => $this->service_name,
|
||||||
));
|
'oauth_token' => serialize($token),
|
||||||
|
));
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +138,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
|
||||||
return true;
|
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(
|
$db->sql_build_array('SELECT', array(
|
||||||
'user_id' => $this->user->data['user_id'],
|
'user_id' => $this->user->data['user_id'],
|
||||||
'oauth_provider' => $this->service_name,
|
'oauth_provider' => $this->service_name,
|
||||||
|
@ -152,7 +162,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface
|
||||||
{
|
{
|
||||||
$this->cachedToken = null;
|
$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);
|
' AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider);
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth token table
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $auth_provider_oauth_table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached service once it has been created
|
* Cached service once it has been created
|
||||||
*
|
*
|
||||||
|
@ -70,17 +77,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
||||||
/**
|
/**
|
||||||
* OAuth Authentication Constructor
|
* OAuth Authentication Constructor
|
||||||
*
|
*
|
||||||
* @param phpbb_db_driver $db
|
* @param phpbb_db_driver $db
|
||||||
* @param phpbb_config $config
|
* @param phpbb_config $config
|
||||||
* @param phpbb_request $request
|
* @param phpbb_request $request
|
||||||
* @param phpbb_user $user
|
* @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->db = $db;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->user = $user;
|
$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;
|
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();
|
$current_uri = $this->get_current_uri();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue