diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-12 12:51:35 -0700 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-12 12:51:35 -0700 |
commit | 86b910692aa1d441c4113294cebe9a12c1d25180 (patch) | |
tree | 87d281546d4e408a58c61fb7fbfd4532f9db7aac /phpBB | |
parent | dfa888c13f13219291fd7ffb1e1357c745832314 (diff) | |
parent | b9f33e5a872af35128629872b5bb60032d25f932 (diff) | |
download | forums-86b910692aa1d441c4113294cebe9a12c1d25180.tar forums-86b910692aa1d441c4113294cebe9a12c1d25180.tar.gz forums-86b910692aa1d441c4113294cebe9a12c1d25180.tar.bz2 forums-86b910692aa1d441c4113294cebe9a12c1d25180.tar.xz forums-86b910692aa1d441c4113294cebe9a12c1d25180.zip |
Merge pull request #1515 from Hardolaf/feature/auth-refactor
[feature/auth-refactor] Use a base class for all authentication providers
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/acp/acp_board.php | 6 | ||||
-rw-r--r-- | phpBB/includes/auth/provider/apache.php | 18 | ||||
-rw-r--r-- | phpBB/includes/auth/provider/base.php | 64 | ||||
-rw-r--r-- | phpBB/includes/auth/provider/db.php | 42 | ||||
-rw-r--r-- | phpBB/includes/auth/provider/ldap.php | 26 | ||||
-rw-r--r-- | phpBB/includes/session.php | 6 |
6 files changed, 78 insertions, 84 deletions
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 +/** +* +* @package auth +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Base authentication provider class that all other providers should implement +* +* @package auth +*/ +abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface +{ + /** + * {@inheritdoc} + */ + public function init() + { + return; + } + + /** + * {@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/db.php b/phpBB/includes/auth/provider/db.php index 894041c9cf..0934c56d9b 100644 --- a/phpBB/includes/auth/provider/db.php +++ b/phpBB/includes/auth/provider/db.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_db implements phpbb_auth_provider_interface +class phpbb_auth_provider_db extends phpbb_auth_provider_base { /** @@ -48,14 +48,6 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface /** * {@inheritdoc} */ - public function init() - { - return; - } - - /** - * {@inheritdoc} - */ public function login($username, $password) { // Auth plugins get the password untrimmed. @@ -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 @@ -286,14 +286,6 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface /** * {@inheritdoc} */ - public function autologin() - { - return; - } - - /** - * {@inheritdoc} - */ public function acp($new) { $tpl = ' @@ -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) { |