diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 24b913260b..7627ff0b56 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -678,8 +678,12 @@ class acp_board $auth_plugins = array(); $auth_providers = $phpbb_container->get('auth.provider_collection'); - foreach($auth_providers as $key => $value) + foreach ($auth_providers as $key => $value) { + if (!($value instanceof phpbb_auth_provider_interface)) + { + continue; + } $auth_plugins[] = str_replace('auth.provider.', '', $key); } diff --git a/phpBB/includes/auth/provider/apache.php b/phpBB/includes/auth/provider/apache.php index 5f6f2862b6..2e80436f78 100644 --- a/phpBB/includes/auth/provider/apache.php +++ b/phpBB/includes/auth/provider/apache.php @@ -20,7 +20,7 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_apache implements phpbb_auth_provider_interface +class phpbb_auth_provider_apache extends phpbb_auth_provider_base { /** * Apache Authentication Constructor @@ -256,20 +256,4 @@ class phpbb_auth_provider_apache implements phpbb_auth_provider_interface return false; } - - /** - * {@inheritdoc} - */ - public function acp($new) - { - return; - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } } diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php new file mode 100644 index 0000000000..f28f352e2c --- /dev/null +++ b/phpBB/includes/auth/provider/base.php @@ -0,0 +1,64 @@ +php_ext = $php_ext; } - /** - * {@inheritdoc} - */ - public function init() - { - return; - } - /** * {@inheritdoc} */ @@ -302,36 +294,4 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface 'user_row' => $row, ); } - - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - - /** - * {@inheritdoc} - */ - public function acp($new) - { - return; - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - return; - } } diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index f67c1e9247..e10986abf0 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface +class phpbb_auth_provider_ldap extends phpbb_auth_provider_base { /** * LDAP Authentication Constructor @@ -283,14 +283,6 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface ); } - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - /** * {@inheritdoc} */ @@ -367,20 +359,4 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface { return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string); } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - return; - } } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 66bf053f7d..e0585b1523 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -404,6 +404,12 @@ class phpbb_session $method = basename(trim($config['auth_method'])); $provider = $phpbb_container->get('auth.provider.' . $method); + + if (!($provider instanceof phpbb_auth_provider_interface)) + { + throw new \RuntimeException($provider . ' must implement phpbb_auth_provider_interface'); + } + $ret = $provider->validate_session($this->data); if ($ret !== null && !$ret) { diff --git a/tests/acp_board/auth_provider/invalid.php b/tests/acp_board/auth_provider/invalid.php new file mode 100644 index 0000000000..c12851afe6 --- /dev/null +++ b/tests/acp_board/auth_provider/invalid.php @@ -0,0 +1,13 @@ +Acp_board_valid'), + array('acp_board_invalid', ''), + ); + } + + public function setUp() + { + parent::setUp(); + + global $phpbb_container; + $phpbb_container = new phpbb_mock_container_builder(); + + $phpbb_container->set('auth.provider_collection', array( + 'auth.provider.acp_board_valid' => new phpbb_auth_provider_acp_board_valid, + 'auth.provider.acp_board_invalid' => new phpbb_auth_provider_acp_board_invalid, + )); + + $this->acp_board = new acp_board(); + } + + /** + * @dataProvider select_auth_method_data + */ + public function test_select_auth_method($selected, $expected) + { + $this->assertEquals($expected, $this->acp_board->select_auth_method($selected)); + } +}