aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2019-11-01 14:37:27 +0100
committerMarc Alexander <admin@m-a-styles.de>2019-11-16 16:02:44 +0100
commita00b8c29204e4517ada908cdc0bc6eacf93d7305 (patch)
tree451b2213f3c8a8e3874821d4b4f202e7ccb78a79
parent9e0c3fc81ec0c3006acc5aa3074cedb98f11e680 (diff)
downloadforums-a00b8c29204e4517ada908cdc0bc6eacf93d7305.tar
forums-a00b8c29204e4517ada908cdc0bc6eacf93d7305.tar.gz
forums-a00b8c29204e4517ada908cdc0bc6eacf93d7305.tar.bz2
forums-a00b8c29204e4517ada908cdc0bc6eacf93d7305.tar.xz
forums-a00b8c29204e4517ada908cdc0bc6eacf93d7305.zip
[ticket/12574] Clean up dependencies of db auth provider
PHPBB3-12574
-rw-r--r--phpBB/config/default/container/services_auth.yml4
-rw-r--r--phpBB/phpbb/auth/provider/db.php61
-rw-r--r--tests/auth/provider_db_test.php14
3 files changed, 55 insertions, 24 deletions
diff --git a/phpBB/config/default/container/services_auth.yml b/phpBB/config/default/container/services_auth.yml
index dfe3ab8be5..bace1bb6cd 100644
--- a/phpBB/config/default/container/services_auth.yml
+++ b/phpBB/config/default/container/services_auth.yml
@@ -15,12 +15,12 @@ services:
auth.provider.db:
class: phpbb\auth\provider\db
arguments:
- - '@dbal.conn'
+ - '@captcha.factory'
- '@config'
+ - '@dbal.conn'
- '@passwords.manager'
- '@request'
- '@user'
- - '@service_container'
- '%core.root_path%'
- '%core.php_ext%'
tags:
diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php
index 1adf85ee05..a70734fcbe 100644
--- a/phpBB/phpbb/auth/provider/db.php
+++ b/phpBB/phpbb/auth/provider/db.php
@@ -13,48 +13,69 @@
namespace phpbb\auth\provider;
+use phpbb\captcha\factory;
+use phpbb\config\config;
+use phpbb\db\driver\driver_interface;
+use phpbb\passwords\manager;
+use phpbb\request\request_interface;
+use phpbb\user;
+
/**
* Database authentication provider for phpBB3
* This is for authentication via the integrated user table
*/
-class db extends \phpbb\auth\provider\base
+class db extends base
{
+ /** @var factory CAPTCHA factory */
+ protected $captcha_factory;
+
+ /** @var config phpBB config */
+ protected $config;
+
+ /** @var driver_interface DBAL driver instance */
+ protected $db;
+
+ /** @var request_interface Request object */
+ protected $request;
+
+ /** @var user User object */
+ protected $user;
+
+ /** @var string phpBB root path */
+ protected $phpbb_root_path;
+
+ /** @var string PHP file extension */
+ protected $php_ext;
+
/**
* phpBB passwords manager
*
- * @var \phpbb\passwords\manager
+ * @var manager
*/
protected $passwords_manager;
/**
- * DI container
- *
- * @var \Symfony\Component\DependencyInjection\ContainerInterface
- */
- protected $phpbb_container;
-
- /**
* Database Authentication Constructor
*
- * @param \phpbb\db\driver\driver_interface $db
- * @param \phpbb\config\config $config
- * @param \phpbb\passwords\manager $passwords_manager
- * @param \phpbb\request\request $request
- * @param \phpbb\user $user
- * @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container
+ * @param factory $captcha_factory
+ * @param config $config
+ * @param driver_interface $db
+ * @param manager $passwords_manager
+ * @param request_interface $request
+ * @param user $user
* @param string $phpbb_root_path
* @param string $php_ext
*/
- public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request $request, \phpbb\user $user, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext)
+ public function __construct(factory $captcha_factory, config $config, driver_interface $db, manager $passwords_manager, request_interface $request, user $user, $phpbb_root_path, $php_ext)
{
- $this->db = $db;
+ $this->captcha_factory = $captcha_factory;
$this->config = $config;
+ $this->db = $db;
$this->passwords_manager = $passwords_manager;
$this->request = $request;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
- $this->phpbb_container = $phpbb_container;
}
/**
@@ -155,9 +176,7 @@ class db extends \phpbb\auth\provider\base
// Every auth module is able to define what to do by itself...
if ($show_captcha)
{
- /* @var $captcha_factory \phpbb\captcha\factory */
- $captcha_factory = $this->phpbb_container->get('captcha.factory');
- $captcha = $captcha_factory->get_instance($this->config['captcha_plugin']);
+ $captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
$captcha->init(CONFIRM_LOGIN);
$vc_response = $captcha->validate($row);
if ($vc_response)
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index b7d94ed046..2c467518f5 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -52,8 +52,20 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
$phpbb_container = new phpbb_mock_container_builder();
+ $plugins = new \phpbb\di\service_collection($phpbb_container);
+ $plugins->add('core.captcha.plugins.nogd');
+ $phpbb_container->set(
+ 'captcha.factory',
+ new \phpbb\captcha\factory($phpbb_container, $plugins)
+ );
+ $phpbb_container->set(
+ 'core.captcha.plugins.nogd',
+ new \phpbb\captcha\plugins\nogd()
+ );
+ /** @var \phpbb\captcha\factory $captcha_factory */
+ $captcha_factory = $phpbb_container->get('captcha.factory');
- $provider = new \phpbb\auth\provider\db($db, $config, $passwords_manager, $request, $user, $phpbb_container, $phpbb_root_path, $phpEx);
+ $provider = new \phpbb\auth\provider\db($captcha_factory, $config, $db, $passwords_manager, $request, $user, $phpbb_root_path, $phpEx);
if (version_compare(PHP_VERSION, '5.3.7', '<'))
{
$password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi';